Skip to content

Commit 8e9addf

Browse files
committed
tests: Reproduer for overriding existing files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
1 parent d3678e7 commit 8e9addf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/unit/sftp_test.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ 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 pre_existing_dst_path(dst_path, other_payload):
62+
"""Return a data destination path."""
63+
dst_path.write_bytes(other_payload)
64+
assert dst_path.exists()
65+
return dst_path
66+
67+
5368
def test_make_sftp(sftp_session):
5469
"""Smoke-test SFTP instance creation."""
5570
assert sftp_session
@@ -67,6 +82,12 @@ def test_get(dst_path, src_path, sftp_session, transmit_payload):
6782
assert dst_path.read_bytes() == transmit_payload
6883

6984

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

0 commit comments

Comments
 (0)