10
10
_get_headers ,
11
11
_get_monitor_config ,
12
12
_patch_beat_apply_entry ,
13
- _patch_redbeat_maybe_due ,
13
+ _patch_redbeat_apply_async ,
14
14
crons_task_failure ,
15
15
crons_task_retry ,
16
16
crons_task_success ,
@@ -454,10 +454,10 @@ def test_exclude_redbeat_tasks_option(
454
454
"""
455
455
Test excluding Celery RedBeat tasks from automatic instrumentation.
456
456
"""
457
- fake_maybe_due = MagicMock ()
457
+ fake_apply_async = MagicMock ()
458
458
459
459
fake_redbeat_scheduler = MagicMock ()
460
- fake_redbeat_scheduler .maybe_due = fake_maybe_due
460
+ fake_redbeat_scheduler .apply_async = fake_apply_async
461
461
462
462
fake_integration = MagicMock ()
463
463
fake_integration .exclude_beat_tasks = exclude_beat_tasks
@@ -481,17 +481,19 @@ def test_exclude_redbeat_tasks_option(
481
481
"sentry_sdk.integrations.celery.beat._get_monitor_config" ,
482
482
fake_get_monitor_config ,
483
483
) as _get_monitor_config :
484
- # Mimic CeleryIntegration patching of RedBeatScheduler.maybe_due ()
485
- _patch_redbeat_maybe_due ()
484
+ # Mimic CeleryIntegration patching of RedBeatScheduler.apply_async ()
485
+ _patch_redbeat_apply_async ()
486
486
# Mimic Celery RedBeat calling a task from the RedBeat schedule
487
- RedBeatScheduler .maybe_due (fake_redbeat_scheduler , fake_schedule_entry )
487
+ RedBeatScheduler .apply_async (
488
+ fake_redbeat_scheduler , fake_schedule_entry
489
+ )
488
490
489
491
if task_in_excluded_beat_tasks :
490
492
# Only the original RedBeatScheduler.maybe_due() is called, _get_monitor_config is NOT called.
491
- assert fake_maybe_due .call_count == 1
493
+ assert fake_apply_async .call_count == 1
492
494
_get_monitor_config .assert_not_called ()
493
495
494
496
else :
495
497
# The original RedBeatScheduler.maybe_due() is called, AND _get_monitor_config is called.
496
- assert fake_maybe_due .call_count == 1
498
+ assert fake_apply_async .call_count == 1
497
499
assert _get_monitor_config .call_count == 1
0 commit comments