@@ -3246,49 +3246,52 @@ def test_operational_error_does_not_cause_recursion(
3246
3246
3247
3247
self .assertIsInstance (retry_args ["exc" ], OperationalError )
3248
3248
self .assertEqual (
3249
- retry_args ["args" ],
3250
- ([self .opinion_1 .id , self .opinion_2 .id ], False , False ),
3249
+ sorted ( retry_args ["args" ][ 0 ]) ,
3250
+ sorted ([self .opinion_1 .id , self .opinion_2 .id ]),
3251
3251
)
3252
- self .assertEqual (retry_args ["countdown" ], 5 )
3252
+ self .assertEqual (retry_args ["args" ][ 1 :], ( False , False ) )
3253
3253
3254
+ self .assertEqual (retry_args ["countdown" ], 5 )
3254
3255
3255
- @patch ("celery.app.task.Task.retry" , side_effect = Retry ())
3256
- @patch ("cl.citations.tasks.store_opinion_citations_and_update_parentheticals" )
3257
- def test_operational_error_accumulates_failed_ids_and_retries_together (
3258
- self , mock_store , mock_retry
3259
- ):
3260
- """Ensure multiple OperationalError cases are retried in batch with self.retry"""
3256
+ @patch ("celery.app.task.Task.retry" , side_effect = Retry ())
3257
+ @patch (
3258
+ "cl.citations.tasks.store_opinion_citations_and_update_parentheticals"
3259
+ )
3260
+ def test_operational_error_accumulates_failed_ids_and_retries_together (
3261
+ self , mock_store , mock_retry
3262
+ ):
3263
+ """Ensure multiple OperationalError cases are retried in batch with self.retry"""
3261
3264
3262
- def side_effect (opinion , * _ ):
3263
- """Mocks store_opinion_citations_and_update_parentheticals call
3264
- Simulates a failure for opinion_1 and opinon_3
3265
+ def side_effect (opinion , * _ ):
3266
+ """Mocks store_opinion_citations_and_update_parentheticals call
3267
+ Simulates a failure for opinion_1 and opinon_3
3265
3268
3266
- :param opinion: The opinion object being processed
3267
- :param *_: Ignored positional arguments passed by the task
3268
- :return: None for all other opinions to simulate success
3269
- """
3270
- if opinion .id in [self .opinion_2 .id , self .opinion_3 .id ]:
3271
- raise OperationalError ()
3272
- return None
3269
+ :param opinion: The opinion object being processed
3270
+ :param *_: Ignored positional arguments passed by the task
3271
+ :return: None for all other opinions to simulate success
3272
+ """
3273
+ if opinion .id in [self .opinion_2 .id , self .opinion_3 .id ]:
3274
+ raise OperationalError ()
3275
+ return None
3273
3276
3274
- mock_store .side_effect = side_effect
3277
+ mock_store .side_effect = side_effect
3275
3278
3276
- with self .assertRaises (Retry ):
3277
- find_citations_and_parentheticals_for_opinion_by_pks .apply (
3278
- args = (
3279
- [self .opinion_1 .id , self .opinion_2 .id , self .opinion_3 .id ],
3280
- False ,
3281
- False ,
3282
- ),
3283
- throw = True ,
3284
- )
3279
+ with self .assertRaises (Retry ):
3280
+ find_citations_and_parentheticals_for_opinion_by_pks .apply (
3281
+ args = (
3282
+ [self .opinion_1 .id , self .opinion_2 .id , self .opinion_3 .id ],
3283
+ False ,
3284
+ False ,
3285
+ ),
3286
+ throw = True ,
3287
+ )
3285
3288
3286
- called_args = mock_retry .call_args .kwargs
3289
+ called_args = mock_retry .call_args .kwargs
3287
3290
3288
- self .assertEqual (called_args ["countdown" ], 5 )
3289
- self .assertIsInstance (called_args ["exc" ], OperationalError )
3290
- self .assertEqual (
3291
- set (called_args ["args" ][0 ]),
3292
- {self .opinion_2 .id , self .opinion_3 .id },
3293
- "Should retry only failed opinion IDs" ,
3294
- )
3291
+ self .assertEqual (called_args ["countdown" ], 5 )
3292
+ self .assertIsInstance (called_args ["exc" ], OperationalError )
3293
+ self .assertEqual (
3294
+ set (called_args ["args" ][0 ]),
3295
+ {self .opinion_2 .id , self .opinion_3 .id },
3296
+ "Should retry only failed opinion IDs" ,
3297
+ )
0 commit comments