Skip to content

Commit 945ae7c

Browse files
committed
tests: Reproduer for overriding existing files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
1 parent 946abfe commit 945ae7c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/unit/sftp_test.py

+22
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ def dst_path(file_paths_pair):
5050
return path
5151

5252

53+
@pytest.fixture
54+
def other_payload():
55+
"""Generate a binary test payload."""
56+
uuid_name = uuid.uuid4()
57+
return 'Original content: {name!s}'.format(name=uuid_name).encode()
58+
59+
60+
@pytest.fixture
61+
def dst_exists_path(file_paths_pair, other_payload):
62+
"""Return a data destination path."""
63+
path = file_paths_pair[1]
64+
path.write_bytes(other_payload)
65+
assert path.exists()
66+
return path
67+
68+
5369
def test_make_sftp(sftp_session):
5470
"""Smoke-test SFTP instance creation."""
5571
assert sftp_session
@@ -67,6 +83,12 @@ def test_get(dst_path, src_path, sftp_session, transmit_payload):
6783
assert dst_path.read_bytes() == transmit_payload
6884

6985

86+
def test_get_existing(dst_exists_path, src_path, sftp_session, transmit_payload):
87+
"""Check that SFTP file download works when target file exists."""
88+
sftp_session.get(str(src_path), str(dst_exists_path))
89+
assert dst_exists_path.read_bytes() == transmit_payload
90+
91+
7092
@pytest.fixture
7193
def large_payload():
7294
"""Generate a large 1025 byte (1024 + 1B) test payload."""

0 commit comments

Comments
 (0)