Exemple #1
0
    def test_it_can_connect(self):
        service = FTPPublishService()

        if 'FTP_URL' not in os.environ:
            return

        config = service.config_from_url(os.environ['FTP_URL'])
        self.assertEqual('test', config['path'])
        self.assertEqual('localhost', config['host'])

        service._transmit(self.item, {}, destination={'config': config})
        self.assertTrue(self.is_item_loaded(config, 'abc.ntf'))
Exemple #2
0
    def is_item_loaded(self, url, uploaded_filename):
        config = FTPPublishService().config_from_url(url)
        with ftplib.FTP(config.get('host')) as ftp:
            ftp.login(config.get('username'), config.get('password'))
            ftp.cwd(config.get('path', ''))
            ftp.set_pasv(config.get('passive', False))

            for filename, facts in ftp.mlsd():
                if filename == uploaded_filename:
                    return True
            return False