Skip to content

Commit

Permalink
ra
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Nov 25, 2024
1 parent 6203a3b commit cc051b4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/transports/test_all_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def custom_transport(request, tmp_path_factory, monkeypatch) -> Transport:
kwargs = {'machine': 'localhost', 'timeout': 30, 'load_system_host_keys': True, 'key_policy': 'AutoAddPolicy'}
elif request.param == 'core.ssh_auto':
kwargs = {'machine': 'localhost'}
# The transport config is store in a indepenednt tmp path to not mix up with the files under operating.
filepath_config = tmp_path_factory.mktemp('transport') / 'config'
monkeypatch.setattr(plugin, 'FILEPATH_CONFIG', filepath_config)
if not filepath_config.exists():
Expand Down Expand Up @@ -497,6 +498,7 @@ def test_put_get_empty_string_file(custom_transport, tmp_path_remote, tmp_path_l
transport.get(remote_file_abs_path, retrieved_file_abs_path)
# overwrite retrieved_file_name
transport.getfile(remote_file_abs_path, retrieved_file_abs_path)
assert 'file_retrieved.txt' in [p.name for p in (local_dir / directory).iterdir()]


def test_put_and_get_tree(custom_transport, tmp_path_remote, tmp_path_local):
Expand Down Expand Up @@ -719,11 +721,18 @@ def test_put(custom_transport, tmp_path_remote, tmp_path_local):
assert transport.isfile(str(remote_workdir / 'prova'))
transport.remove(str(remote_workdir / 'prova'))

# fourth test put: can't copy more than one file on the same file,
# fourth test put: can't copy more than one file to the same file,
# i.e., the destination should be a folder
with pytest.raises(OSError):
transport.put(str(local_base_dir / '*.txt'), str(remote_workdir / 'prova'))

# can't copy folder to an exist file
with open(remote_workdir / 'existing.txt', 'w', encoding='utf8') as fhandle:
fhandle.write(text)
with pytest.raises(OSError):
transport.put(str(local_base_dir), str(remote_workdir / 'existing.txt'))
transport.remove(str(remote_workdir / 'existing.txt'))

# fifth test, copying one file into a folder
transport.mkdir(str(remote_workdir / 'prova'))
transport.put(str(local_base_dir / 'a.txt'), str(remote_workdir / 'prova'))
Expand Down Expand Up @@ -1056,7 +1065,6 @@ def test_transfer_big_stdout(custom_transport, tmp_path_remote):
fcontent = (file_line_binary * line_repetitions).decode('utf8')

with custom_transport as transport:
transport: Transport
# We cannot use tempfile.mkdtemp because we're on a remote folder
directory_name = 'temp_dir_test_transfer_big_stdout'
directory_path = tmp_path_remote / directory_name
Expand Down

0 comments on commit cc051b4

Please sign in to comment.