Skip to content

Commit

Permalink
Add a dedicated test for SSHRemoteIO for upload and download
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Sep 21, 2023
1 parent df56d00 commit 62ef796
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions datalad_ria/tests/test_ssh_remote_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,35 @@ def test_SSHRemoteIO_symlink(ssh_remote_wdir):
# verify that we can remove a symlink
ssh_remoteio.remove(targetfpath)
assert not ssh_remoteio.exists(targetfpath)


def test_SSHRemoteIO_updownload(ssh_remote_wdir, tmp_path):
ssh_remoteio, targetdir = ssh_remote_wdir
probefpath = tmp_path / 'probe'
content = 'dummy'
probefpath.write_text(content)

def noop_callback(val):
pass

ssh_remoteio.put(
probefpath, targetdir / 'myupload', noop_callback)
assert ssh_remoteio.exists(targetdir / 'myupload')
ssh_remoteio.get(
targetdir / 'myupload', tmp_path / 'mydownload', noop_callback)
assert (tmp_path / 'mydownload').read_text() == content

# rename and redownload
renamed_targetfpath = targetdir / 'probe'
ssh_remoteio.rename(targetdir / 'myupload', renamed_targetfpath)
ssh_remoteio.get(
renamed_targetfpath, tmp_path / 'mydownload2', noop_callback)
assert (tmp_path / 'mydownload').read_text() \
== (tmp_path / 'mydownload2').read_text()

# redo upload, overwriting the renamed file
probefpath.write_text('allnew')
ssh_remoteio.put(
probefpath, renamed_targetfpath, noop_callback)
assert ssh_remoteio.exists(renamed_targetfpath)
assert ssh_remoteio.read_file(renamed_targetfpath) == 'allnew'

0 comments on commit 62ef796

Please sign in to comment.