def test_get(self): with temporary_file() as temp_filename: sftp = SFTPClient('localhost', port=2222, username='******', password='******') sftp.get_file_from_uri(remotepath='/vagrant/Vagrantfile', localpath=temp_filename, contact_email=None) self.assertFalse(os.stat(temp_filename)[6] == 0)
def test_import_statements(self): """Tests to make sure all the modules were imported correctly""" class Props(object): pass logging.basicConfig(level=1000) sftp = SFTPClient('fake-hostname--dot-com') props = EmailProps('fake-hostname--dot-com', 22, 'get@me', []) sftp.get_file_from_uri('/path/does/not/exist', '/path/no/good', props)
def test_key_based_auth(self): server = 'localhost' port = 2222 username = '******' key_path = 'id_rsa' with temporary_key(filename=key_path): sftp = SFTPClient(server, port, username, private_key=key_path) sftp.put(os.path.realpath(__file__), os.path.basename(__file__))
def test_put_into_nested_directories(self): server = 'localhost' port = 2222 username = '******' password = '******' sftp = SFTPClient(server, port, username, password) local_path = os.path.realpath(__file__) remote_path = './tmp/subtmp/' + os.path.basename(__file__) sftp.put(local_path, remote_path)
def test_put_with_password(self): server = 'localhost' port = 2222 username = '******' password = '******' sftp = SFTPClient(server, port, username, password) local_path = os.path.realpath(__file__) remote_path = os.path.basename(__file__) sftp.put(local_path, remote_path)
def test_get(self): with temporary_file() as temp_filename: sftp = SFTPClient('localhost', port=2222, username='******', password='******') sftp.get_file_from_uri(remote_path='/vagrant/Vagrantfile', local_path=temp_filename, props=None) self.assertFalse(os.stat(temp_filename)[6] == 0)