Пример #1
0
    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)
Пример #2
0
    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()
Пример #3
0
    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()
Пример #4
0
    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)
Пример #5
0
 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)
Пример #6
0
 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)