diff --git a/arxiv/integration/fastly/purge.py b/arxiv/integration/fastly/purge.py index e31304ff..b7588ef2 100644 --- a/arxiv/integration/fastly/purge.py +++ b/arxiv/integration/fastly/purge.py @@ -143,13 +143,13 @@ def _purge_multiple_keys(keys: List[str], service_id:str, api_instance: PurgeApi if len(keys)> MAX_PURGE_KEYS: _purge_multiple_keys(keys[0:MAX_PURGE_KEYS], service_id, api_instance, soft_purge) _purge_multiple_keys(keys[MAX_PURGE_KEYS:], service_id, api_instance,soft_purge) - - options = { - 'service_id': service_id, - 'purge_response': {'surrogate_keys':keys,} - } - if soft_purge: - options['fastly_soft_purge']=1 - api_response=api_instance.bulk_purge_tag(**options) - logger.debug(f"Bulk purge keys response: {api_response}") + else: + options = { + 'service_id': service_id, + 'purge_response': {'surrogate_keys':keys,} + } + if soft_purge: + options['fastly_soft_purge']=1 + api_response=api_instance.bulk_purge_tag(**options) + logger.debug(f"Bulk purge keys response: {api_response}") return diff --git a/arxiv/integration/tests/test_fastly.py b/arxiv/integration/tests/test_fastly.py index 116608a5..c3486cc5 100644 --- a/arxiv/integration/tests/test_fastly.py +++ b/arxiv/integration/tests/test_fastly.py @@ -77,6 +77,7 @@ def test_purge_over_max_keys(self, MockApiClient, MockPurgeApi: PurgeApi): ] mock_api_instance.bulk_purge_tag.assert_has_calls(calls, any_order=True) + self.assertEqual(mock_api_instance.bulk_purge_tag.call_count, len(calls)) #tests for adding surrogate keys helper function