Esempio n. 1
0
    def test_local(self):
        """
        Test with a file:// scheme.
        """
        url = 'file:///martin.com/test'
        nectar_config = config.DownloaderConfig(max_concurrent=23)

        downloader = Importer.build_downloader(url, nectar_config)

        self.assertTrue(isinstance(downloader, local.LocalFileDownloader))
        self.assertEqual(downloader.config.max_concurrent, 23)
Esempio n. 2
0
    def test_http(self):
        """
        Test with http:// as the scheme.
        """
        url = 'http://martin.com/test'
        nectar_config = config.DownloaderConfig(max_speed=42)

        downloader = Importer.build_downloader(url, nectar_config)

        self.assertTrue(isinstance(downloader, threaded.HTTPThreadedDownloader))
        self.assertEqual(downloader.config.max_speed, 42)
Esempio n. 3
0
    def test_https(self, _process_ssl_settings):
        """
        Test with https:// as the scheme.
        """
        url = 'https://martin.com/test'
        nectar_config = config.DownloaderConfig(
            ssl_ca_cert='CA Cert', ssl_ca_cert_path='/path/to/ca.crt',
            ssl_client_cert='Client Cert', ssl_client_cert_path='/path/to/client.crt',
            ssl_client_key='Client Cert', ssl_client_key_path='/path/to/client.key')

        downloader = Importer.build_downloader(url, nectar_config)

        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')
        _process_ssl_settings.assert_called_once_with()