コード例 #1
0
 def test_doesnt_pass_user_agent_when_not_set(self):
     mock_UrlMirrorReader = self.patch(download_descriptions,
                                       "UrlMirrorReader")
     self.patch(download_descriptions.RepoDumper, "sync")
     path = factory.make_url()
     download_descriptions.download_image_descriptions(path)
     self.assertThat(mock_UrlMirrorReader,
                     MockCalledOnceWith(ANY, policy=ANY))
コード例 #2
0
 def test_passes_user_agent(self):
     mock_UrlMirrorReader = self.patch(download_descriptions,
                                       "UrlMirrorReader")
     self.patch(download_descriptions.RepoDumper, "sync")
     path = factory.make_url()
     user_agent = factory.make_name("agent")
     download_descriptions.download_image_descriptions(
         path, user_agent=user_agent)
     self.assertThat(
         mock_UrlMirrorReader,
         MockCalledOnceWith(ANY, policy=ANY, user_agent=user_agent))
コード例 #3
0
 def test_doesnt_pass_user_agenton_fallback(self):
     mock_UrlMirrorReader = self.patch(download_descriptions,
                                       "UrlMirrorReader")
     mock_UrlMirrorReader.side_effect = [TypeError(), Mock()]
     self.patch(download_descriptions.RepoDumper, "sync")
     path = factory.make_url()
     user_agent = factory.make_name("agent")
     download_descriptions.download_image_descriptions(
         path, user_agent=user_agent)
     self.assertThat(
         mock_UrlMirrorReader,
         MockCallsMatch(
             call(ANY, policy=ANY, user_agent=user_agent),
             call(ANY, policy=ANY),
         ),
     )