def test_local(self): """ Test with a file:// scheme. """ url = 'file:///martin.com/test' importer = Mock() importer.config = {importer_constants.KEY_MAX_DOWNLOADS: 123} downloader = Importer.get_downloader_for_db_importer(importer, url, '/working/dir') self.assertTrue(isinstance(downloader, local.LocalFileDownloader)) self.assertEqual(downloader.config.max_concurrent, 123) self.assertEqual(downloader.config.working_dir, '/working/dir')
def test_http(self): """ Test with http:// as the scheme. """ url = 'http://martin.com/test' importer = Mock() importer.config = {importer_constants.KEY_MAX_SPEED: 5555} downloader = Importer.get_downloader_for_db_importer(importer, url, '/working/dir') self.assertTrue(isinstance(downloader, threaded.HTTPThreadedDownloader)) self.assertEqual(downloader.config.max_speed, 5555) self.assertEqual(downloader.config.working_dir, '/working/dir')
def test_https(self, _process_ssl_settings): """ Test with https:// as the scheme. """ url = 'https://martin.com/test' importer = Mock() importer.config = { importer_constants.KEY_SSL_CA_CERT: 'CA Cert', importer_constants.KEY_SSL_CLIENT_CERT: 'Client Cert', importer_constants.KEY_SSL_CLIENT_KEY: 'Client Key'} importer.tls_ca_cert_path = '/path/to/ca.crt' importer.tls_client_cert_path = '/path/to/client.crt' importer.tls_client_key_path = '/path/to/client.key' downloader = Importer.get_downloader_for_db_importer(importer, url, '/working/dir') self.assertTrue(isinstance(downloader, threaded.HTTPThreadedDownloader)) self.assertEqual(downloader.config.ssl_ca_cert_path, '/path/to/ca.crt') self.assertEqual(downloader.config.ssl_client_cert_path, '/path/to/client.crt') self.assertEqual(downloader.config.ssl_client_key_path, '/path/to/client.key') self.assertEqual(downloader.config.working_dir, '/working/dir') _process_ssl_settings.assert_called_once_with()