Ejemplo n.º 1
0
 def test_download_url_http_error(self, mocked_urlretrieve, mocked_error,
                                  _):
     """Tests that download_url doesn't retry when there is an HTTP error."""
     self.assertFalse(fuzz_target.download_url(self.URL, self.FILE_PATH))
     mocked_error.assert_called_with('Unable to download from: %s.',
                                     self.URL)
     self.assertEqual(1, mocked_urlretrieve.call_count)
Ejemplo n.º 2
0
 def test_download_url_connection_error(self, mocked_urlretrieve, mocked_error,
                                        mocked_sleep):
   """Tests that download_url doesn't retry when there is an HTTP error."""
   self.assertFalse(fuzz_target.download_url(self.URL, self.FILE_PATH))
   self.assertEqual(3, mocked_urlretrieve.call_count)
   self.assertEqual(3, mocked_sleep.call_count)
   mocked_error.assert_called_with('Failed to download %s, %d times.',
                                   self.URL, 3)
Ejemplo n.º 3
0
 def test_download_url_no_error(self, mocked_urlretrieve, _):
   """Tests that download_url works when there is no error."""
   self.assertTrue(fuzz_target.download_url(self.URL, self.FILE_PATH))
   self.assertEqual(1, mocked_urlretrieve.call_count)