Skip to content

Commit 363e53d

Browse files
author
Kincaid Savoie
committed
Added test for recursive use of copy_file.
1 parent 2379b7a commit 363e53d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_ssh_client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,28 @@ def test_ssh_client_sftp(self):
141141
os.rmdir(dirpath)
142142
del client
143143

144+
def test_ssh_client_directory(self):
145+
"""Tests copying directories with SSH client. Copy all the files from
146+
local directory to server, then make sure they are all present."""
147+
test_file_data = 'test'
148+
local_test_path = 'directory_test'
149+
remote_test_path = 'directory_test_copied'
150+
os.mkdir(local_test_path)
151+
remote_file_paths = []
152+
for i in range(0, 10):
153+
local_file_path = os.path.join(local_test_path, 'foo' + str(i))
154+
remote_file_path = os.path.join(remote_test_path, 'foo' + str(i))
155+
remote_file_paths.append(remote_file_path)
156+
test_file = open(local_file_path, 'w')
157+
test_file.write(test_file_data)
158+
test_file.close()
159+
client = SSHClient(self.host, port=self.listen_port,
160+
pkey=self.user_key)
161+
client.copy_file(local_test_path, remote_test_path)
162+
for path in remote_file_paths:
163+
self.assertTrue(os.path.isfile(path))
164+
165+
144166
def test_ssh_agent_authentication(self):
145167
"""Test authentication via SSH agent.
146168
Do not provide public key to use when creating SSHClient,

0 commit comments

Comments
 (0)