@@ -153,7 +153,7 @@ def test_ssh_client_sftp(self):
153153 os .rmdir (dirpath )
154154 del client
155155
156- def test_ssh_client_directory (self ):
156+ def test_ssh_client_local_directory (self ):
157157 """Tests copying directories with SSH client. Copy all the files from
158158 local directory to server, then make sure they are all present."""
159159 test_file_data = 'test'
@@ -181,6 +181,28 @@ def test_ssh_client_directory(self):
181181 shutil .rmtree (local_test_path )
182182 shutil .rmtree (remote_test_path )
183183
184+ def test_ssh_client_copy_remote_directory (self ):
185+ """Tests copying a remote directory to the localhost"""
186+ remote_test_directory = 'remote_test_dir'
187+ local_test_directory = 'local_test_dir'
188+ os .mkdir (remote_test_directory )
189+ test_files = []
190+ for i in range (0 , 10 ):
191+ file_name = 'foo' + str (i )
192+ test_files .append (file_name )
193+ file_path = os .path .join (remote_test_directory , file_name )
194+ test_file = open (file_path , 'w' )
195+ test_file .write ('test' )
196+ test_file .close ()
197+ client = SSHClient (self .host , port = self .listen_port ,
198+ pkey = self .user_key )
199+ client .copy_file_to_local (remote_test_directory , local_test_directory , recurse = True )
200+ for test_file in test_files :
201+ file_path = os .path .join (local_test_directory , test_file )
202+ self .assertTrue (os .path .exists (file_path ))
203+ shutil .rmtree (remote_test_directory )
204+ shutil .rmtree (local_test_directory )
205+
184206 def test_ssh_client_directory_no_recurse (self ):
185207 """Tests copying directories with SSH client. Copy all the files from
186208 local directory to server, then make sure they are all present."""
0 commit comments