Ejemplo n.º 1
0
    def setUpClass(cls):
        TestDownloaderBase.setUpClass()
        cls.downloader = downloader.find("http")(cls.extractor, NullOutput())

        port = 8088
        cls.address = "http://127.0.0.1:{}".format(port)
        cls._jpg = cls.address + "/image.jpg"
        cls._png = cls.address + "/image.png"
        cls._gif = cls.address + "/image.gif"

        server = http.server.HTTPServer(("", port), HttpRequestHandler)
        threading.Thread(target=server.serve_forever, daemon=True).start()
Ejemplo n.º 2
0
    def setUpClass(cls):
        TestDownloaderBase.setUpClass()
        cls.downloader = downloader.find("http")(cls.extractor, NullOutput())

        port = 8088
        cls.address = "http://127.0.0.1:{}".format(port)
        cls._jpg = cls.address + "/image.jpg"
        cls._png = cls.address + "/image.png"
        cls._gif = cls.address + "/image.gif"

        server = http.server.HTTPServer(("", port), HttpRequestHandler)
        threading.Thread(target=server.serve_forever, daemon=True).start()
Ejemplo n.º 3
0
    def test_find(self):
        cls = downloader.find("http")
        self.assertEqual(cls.__name__, "HttpDownloader")
        self.assertEqual(cls.scheme  , "http")

        cls = downloader.find("https")
        self.assertEqual(cls.__name__, "HttpDownloader")
        self.assertEqual(cls.scheme  , "http")

        cls = downloader.find("text")
        self.assertEqual(cls.__name__, "TextDownloader")
        self.assertEqual(cls.scheme  , "text")

        cls = downloader.find("ytdl")
        self.assertEqual(cls.__name__, "YoutubeDLDownloader")
        self.assertEqual(cls.scheme  , "ytdl")

        self.assertEqual(downloader.find("ftp"), None)
        self.assertEqual(downloader.find("foo"), None)
        self.assertEqual(downloader.find(1234) , None)
        self.assertEqual(downloader.find(None) , None)
Ejemplo n.º 4
0
 def test_cache_https(self, import_module):
     import_module.return_value = MockDownloaderModule()
     downloader.find("https")
     downloader.find("http")
     self.assertEqual(import_module.call_count, 1)
Ejemplo n.º 5
0
 def setUpClass(cls):
     TestDownloaderBase.setUpClass()
     cls.downloader = downloader.find("text")(cls.extractor, NullOutput())
Ejemplo n.º 6
0
 def setUpClass(cls):
     TestDownloaderBase.setUpClass()
     cls.downloader = downloader.find("text")(cls.job)
Ejemplo n.º 7
0
 def setUpClass(cls):
     TestDownloaderBase.setUpClass()
     cls.downloader = downloader.find("text")(cls.extractor, NullOutput())