Exemplo n.º 1
0
 def test_user_agent_header(self):
     remote = Remote.objects.create(url="http://example.org/", name="foo")
     factory = DownloaderFactory(remote)
     downloader = factory.build(remote.url)
     default_user_agent = DownloaderFactory.user_agent()
     self.assertEqual(downloader.session.headers["User-Agent"], default_user_agent)
     remote.delete()
Exemplo n.º 2
0
 def test_custom_user_agent_header(self):
     remote = Remote.objects.create(
         url="http://example.org/", headers=[{"User-Agent": "foo"}], name="foo"
     )
     factory = DownloaderFactory(remote)
     downloader = factory.build(remote.url)
     default_user_agent = DownloaderFactory.user_agent()
     expected_user_agent = f"{default_user_agent}, foo"
     self.assertEqual(downloader.session.headers["User-Agent"], expected_user_agent)
     remote.delete()