From 650814a6bf35cd86705b87fff2b39bbe7afb3a23 Mon Sep 17 00:00:00 2001 From: Daniel Bernstein Date: Tue, 10 Sep 2024 14:33:16 -0700 Subject: [PATCH] Ensures that the overdrive new titles script does not fail when coverage records are added. --- src/palace/manager/core/coverage.py | 6 ++---- tests/manager/core/test_coverage.py | 6 ------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/palace/manager/core/coverage.py b/src/palace/manager/core/coverage.py index 6a21cb5aa4..53cf0e5ad8 100644 --- a/src/palace/manager/core/coverage.py +++ b/src/palace/manager/core/coverage.py @@ -383,7 +383,7 @@ def run_once(self, progress, count_as_covered=None): transient_failures, persistent_failures, ), results = self.process_batch_and_handle_results(batch_results) - + self.finalize_batch() # Update the running totals so that the service's eventual timestamp # will have a useful .achievements. progress.successes += successes @@ -486,9 +486,6 @@ def process_batch_and_handle_results(self, batch): num_ignored, ) - # Finalize this batch before moving on to the next one. - self.finalize_batch() - # For all purposes outside this method, treat an ignored identifier # as a transient failure. transient_failures += num_ignored @@ -910,6 +907,7 @@ def run_on_specific_identifiers(self, identifiers): while index < len(need_coverage): batch = need_coverage[index : index + self.batch_size] (s, t, p), r = self.process_batch_and_handle_results(batch) + self.finalize_batch() successes += s transient_failures += t persistent_failures += p diff --git a/tests/manager/core/test_coverage.py b/tests/manager/core/test_coverage.py index 41d809e5e1..9ddc39732a 100644 --- a/tests/manager/core/test_coverage.py +++ b/tests/manager/core/test_coverage.py @@ -535,9 +535,6 @@ def test_process_batch_and_handle_results(self, db: DatabaseTransactionFixture): class MockProvider1(AlwaysSuccessfulCoverageProvider): OPERATION = "i succeed" - def finalize_batch(self): - self.finalized = True - success_provider = MockProvider1(db.session) batch = [i1, i2] @@ -546,9 +543,6 @@ def finalize_batch(self): # Two successes. assert (2, 0, 0) == counts - # finalize_batch() was called. - assert True == success_provider.finalized - # Each represented with a CoverageRecord with status='success' assert all(isinstance(x, CoverageRecord) for x in successes) assert [CoverageRecord.SUCCESS] * 2 == [x.status for x in successes]