diff --git a/tests/manager/core/test_coverage.py b/tests/manager/core/test_coverage.py index 9ddc39732..fabe00c56 100644 --- a/tests/manager/core/test_coverage.py +++ b/tests/manager/core/test_coverage.py @@ -515,6 +515,7 @@ def process_batch_and_handle_results(self, batch): assert 1 == progress.successes assert 2 == progress.transient_failures assert 3 == progress.persistent_failures + assert provider.finalize_batch_called assert ( "Items processed: 6. Successes: 1, transient failures: 2, persistent failures: 3" @@ -608,6 +609,9 @@ class MockProvider4(NeverSuccessfulCoverageProvider): assert [CoverageRecord.PERSISTENT_FAILURE] * 2 == [x.status for x in results] assert ["i will always fail"] * 2 == [x.operation for x in results] + assert not success_provider.finalize_batch_called + assert not persistent_failure_provider.finalize_batch_called + def test_process_batch(self, db: DatabaseTransactionFixture): class Mock(BaseCoverageProvider): SERVICE_NAME = "Some succeed, some fail." @@ -1150,6 +1154,8 @@ def test_run_on_specific_identifiers(self, db: DatabaseTransactionFixture): for i in not_to_be_tested: assert i not in provider.attempts + assert provider.finalize_batch_called + def test_run_on_specific_identifiers_respects_cutoff_time( self, db: DatabaseTransactionFixture ): @@ -1193,6 +1199,7 @@ def test_run_on_specific_identifiers_respects_cutoff_time( # reflect the failure. assert records[0] == record assert "What did you expect?" == record.exception + assert provider.finalize_batch_called def test_run_never_successful(self, db: DatabaseTransactionFixture): """Verify that NeverSuccessfulCoverageProvider works the diff --git a/tests/mocks/mock.py b/tests/mocks/mock.py index f0fa9af57..cdca136a3 100644 --- a/tests/mocks/mock.py +++ b/tests/mocks/mock.py @@ -102,11 +102,15 @@ class InstrumentedCoverageProvider(MockCoverageProvider, IdentifierCoverageProvi def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.attempts = [] + self.finalize_batch_called = False def process_item(self, item): self.attempts.append(item) return item + def finalize_batch(self): + self.finalize_batch_called = True + class InstrumentedWorkCoverageProvider(MockCoverageProvider, WorkCoverageProvider): """A WorkCoverageProvider that keeps track of every item it tried