Skip to content

Commit 9001f9a

Browse files
committed
tests: Reproducer for #341
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
1 parent e9935cb commit 9001f9a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/unit/sftp_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
"""Tests suite for sftp."""
44

5+
import random
6+
import string
57
import uuid
68

79
import pytest
@@ -63,3 +65,29 @@ def test_get(dst_path, src_path, sftp_session, transmit_payload):
6365
"""Check that SFTP file download works."""
6466
sftp_session.get(str(src_path), str(dst_path))
6567
assert dst_path.read_bytes() == transmit_payload
68+
69+
70+
@pytest.fixture
71+
def large_payload():
72+
"""Generate a large 1025 byte (1024 + 1B) test payload."""
73+
payload_len = 1024 + 1
74+
random_bytes = [ord(random.choice(string.printable)) for _ in range(payload_len)]
75+
return bytes(random_bytes)
76+
77+
78+
@pytest.fixture
79+
def src_path_large(tmp_path, large_payload):
80+
"""Return a remote path to a 1025 byte-sized file.
81+
82+
The pylibssh chunk size is 1024 so the test needs a file that would
83+
execute at least two loops.
84+
"""
85+
path = tmp_path / 'large.txt'
86+
path.write_bytes(large_payload)
87+
return path
88+
89+
90+
def test_get_large(dst_path, src_path_large, sftp_session, large_payload):
91+
"""Check that SFTP can download large file."""
92+
sftp_session.get(str(src_path_large), str(dst_path))
93+
assert dst_path.read_bytes() == large_payload

0 commit comments

Comments
 (0)