def test_create_directory(self): with fh.FTPHook() as ftp_hook: ftp_hook.create_directory(self.path) self.conn_mock.mkd.assert_called_once_with(self.path)
def test_list_directory(self): with fh.FTPHook() as ftp_hook: ftp_hook.list_directory(self.path) self.conn_mock.cwd.assert_called_once_with(self.path) self.conn_mock.nlst.assert_called_once_with()
def test_close_conn(self): ftp_hook = fh.FTPHook() ftp_hook.get_conn() ftp_hook.close_conn() self.conn_mock.quit.assert_called_once_with()
def test_delete_file(self): with fh.FTPHook() as ftp_hook: ftp_hook.delete_file(self.path) self.conn_mock.delete.assert_called_once_with(self.path)
def test_retrieve_file_with_callback(self): func = mock.Mock() _buffer = io.StringIO('buffer') with fh.FTPHook() as ftp_hook: ftp_hook.retrieve_file(self.path, _buffer, callback=func) self.conn_mock.retrbinary.assert_called_once_with('RETR path', func)
def test_retrieve_file(self): _buffer = io.StringIO('buffer') with fh.FTPHook() as ftp_hook: ftp_hook.retrieve_file(self.path, _buffer) self.conn_mock.retrbinary.assert_called_once_with( 'RETR path', _buffer.write)