Skip to content

Commit

Permalink
tests: Reproduer for overriding existing files
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Nov 15, 2024
1 parent 5ae4af8 commit 9d64dcc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/sftp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ def dst_path(file_paths_pair):
return path


@pytest.fixture
def other_payload():
"""Generate a binary test payload."""
uuid_name = uuid.uuid4()
return 'Original content: {name!s}'.format(name=uuid_name).encode()


@pytest.fixture
def dst_exists_path(file_paths_pair, other_payload):
"""Return a data destination path."""
path = file_paths_pair[1]
path.write_bytes(other_payload)
assert path.exists()
return path


def test_make_sftp(sftp_session):
"""Smoke-test SFTP instance creation."""
assert sftp_session
Expand All @@ -67,6 +83,12 @@ def test_get(dst_path, src_path, sftp_session, transmit_payload):
assert dst_path.read_bytes() == transmit_payload


def test_get_existing(dst_exists_path, src_path, sftp_session, transmit_payload):
"""Check that SFTP file download works when target file exists."""
sftp_session.get(str(src_path), str(dst_exists_path))
assert dst_exists_path.read_bytes() == transmit_payload


@pytest.fixture
def large_payload():
"""Generate a large 1025 byte (1024 + 1B) test payload."""
Expand Down

0 comments on commit 9d64dcc

Please sign in to comment.