Example #1
0
    def test_counts_attempts_with_temporary_exceptions(self, fetch_method):
        attemps = self.test_job.fetch_attempts
        fetch_method.side_effect = TemporaryFetchIssue("ERROR")
        fetch.apply(args=[self.test_job.id])

        self.test_job.refresh_from_db()
        self.assertEqual(attemps + 1, self.test_job.fetch_attempts)
Example #2
0
    def test_counts_attempts_with_temporary_exceptions(self, fetch_method):
        attemps = self.test_job.fetch_attempts
        fetch_method.side_effect = TemporaryFetchIssue("ERROR")
        fetch.apply(args=[self.test_job.id])

        self.test_job.refresh_from_db()
        self.assertEqual(attemps + 1, self.test_job.fetch_attempts)
Example #3
0
    def test_temporary_exception_when_fetching(self, fetch_method):
        fetch_method.side_effect = TemporaryFetchIssue("ERROR")
        fetch.apply(args=[self.test_job.id])

        self.test_job.refresh_from_db()
        self.assertEqual("ERROR", self.test_job.failure)
        self.assertFalse(self.test_job.fetched)
Example #4
0
    def test_temporary_exception_when_fetching(self, fetch_method):
        fetch_method.side_effect = TemporaryFetchIssue("ERROR")
        fetch.apply(args=[self.test_job.id])

        self.test_job.refresh_from_db()
        self.assertEqual("ERROR", self.test_job.failure)
        self.assertFalse(self.test_job.fetched)
Example #5
0
    def test_really_fetch(self, really_fetch_method):
        group = core_models.Group.objects.create(slug='test')
        project = group.projects.create(slug='test')

        backend = models.Backend.objects.create()
        test_job = models.TestJob.objects.create(backend=backend,
                                                 target=project)

        fetch.apply(args=[test_job.id])
        really_fetch_method.assert_called_with(test_job)
Example #6
0
    def test_clear_exception_after_successful_fetch(self, job_url, fetch_method):
        fetch_method.side_effect = TemporaryFetchIssue("ERROR")
        fetch.apply(args=[self.test_job.id])

        self.test_job.refresh_from_db()
        self.assertEqual("ERROR", self.test_job.failure)
        self.assertFalse(self.test_job.fetched)

        fetch_method.side_effect = FetchTest.mock_backend_fetch
        job_url.side_effect = lambda a: 'test'
        fetch.apply(args=[self.test_job.id])
        self.test_job.refresh_from_db()
        fetch_method.assert_called_with(self.test_job)
        self.assertIsNone(self.test_job.failure)
        self.assertTrue(self.test_job.fetched)
Example #7
0
 def test_really_fetch(self, really_fetch_method):
     fetch.apply(args=[self.test_job.id])
     really_fetch_method.assert_called_with(self.test_job)
Example #8
0
 def test_really_fetch(self, really_fetch_method):
     fetch.apply(args=[self.test_job.id])
     really_fetch_method.assert_called_with(self.test_job)