Skip to content

Commit

Permalink
Updated tests to correctly test with multiple directories when copyin…
Browse files Browse the repository at this point in the history
…g files. Resolves #64. Bumped version
  • Loading branch information
pkittenis committed Sep 15, 2016
1 parent 5d202ca commit 05aec5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 10 additions & 0 deletions pssh/pssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ def __init__(self, hosts,
:param proxy_port: (Optional) SSH port to use to login to proxy host if \
set. Defaults to 22.
:type proxy_port: int
:param proxy_user: (Optional) User to login to ``proxy_host`` as. Defaults to \
logged in user.
:type proxy_user: str
:param proxy_password: (Optional) Password to login to ``proxy_host`` with. \
Defaults to no password
:type proxy_password: str
:param proxy_pkey: (Optional) Private key to be used for authentication \
with ``proxy_host``. Defaults to available keys from SSHAgent and user's \
home directory keys
:type proxy_pkey: :mod:`paramiko.PKey`
:param agent: (Optional) SSH agent object to programmatically supply an \
agent to override system SSH agent with
:type agent: :mod:`pssh.agent.SSHAgent`
Expand Down
5 changes: 2 additions & 3 deletions pssh/ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,9 @@ def copy_file(self, local_file, remote_file, recurse=False):
:param recurse: Whether or not to descend into directories recursively.
:type recurse: bool
:raises: :mod:`ValueError` when a directory is supplied to local_file \
and recurse is not set
:raises: :mod:`ValueError` when a directory is supplied to ``local_file`` \
and ``recurse`` is not set
"""
# import ipdb; ipdb.set_trace()
if os.path.isdir(local_file) and recurse:
return self._copy_dir(local_file, remote_file)
elif os.path.isdir(local_file) and not recurse:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
convert_2_to_3['use_2to3'] = True

setup(name='parallel-ssh',
version='0.92.1',
version='0.92.2',
description='Asynchronous parallel SSH library',
author='Panos Kittenis',
author_email='[email protected]',
Expand Down
10 changes: 6 additions & 4 deletions tests/test_pssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def tearDown(self):
del self.server
del self.listen_socket
del self.client

def test_pssh_client_exec_command(self):
cmd = self.client.exec_command(self.fake_cmd)[0]
output = self.client.get_stdout(cmd)
Expand Down Expand Up @@ -360,7 +360,7 @@ def test_pssh_copy_file(self):
del client

def test_pssh_client_directory(self):
"""Tests copying directories with SSH client. Copy all the files from
"""Tests copying multiple directories with SSH client. Copy all the files from
local directory to server, then make sure they are all present."""
test_file_data = 'test'
local_test_path = 'directory_test'
Expand All @@ -373,8 +373,10 @@ def test_pssh_client_directory(self):
os.mkdir(local_test_path)
remote_file_paths = []
for i in range(0, 10):
local_file_path = os.path.join(local_test_path, 'foo' + str(i))
remote_file_path = os.path.join(remote_test_path, 'foo' + str(i))
local_file_path_dir = os.path.join(local_test_path, 'dir_foo' + str(i))
os.mkdir(local_file_path_dir)
local_file_path = os.path.join(local_file_path_dir, 'foo' + str(i))
remote_file_path = os.path.join(remote_test_path, 'dir_foo' + str(i), 'foo' + str(i))
remote_file_paths.append(remote_file_path)
test_file = open(local_file_path, 'w')
test_file.write(test_file_data)
Expand Down

0 comments on commit 05aec5b

Please sign in to comment.