From ea677be6afa31220c35360aae0264763447eae7c Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 30 Jul 2026 10:38:56 -0400 Subject: [PATCH] Align cleanup task tests with unconditional cron string The scheduled cleanup task now always carries the configured cron string, so assert that instead of expecting None, and set the cron string to None explicitly to exercise the unschedule branch in init(). Co-Authored-By: Claude Opus 5 (1M context) --- .../tasks/test_cleanup_orphaned_resources.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/backend/tests/tasks/test_cleanup_orphaned_resources.py b/backend/tests/tasks/test_cleanup_orphaned_resources.py index 9f630e796..c07c3faf4 100644 --- a/backend/tests/tasks/test_cleanup_orphaned_resources.py +++ b/backend/tests/tasks/test_cleanup_orphaned_resources.py @@ -25,17 +25,18 @@ class TestCleanupOrphanedResourcesTask: assert task.enabled is True assert task.manual_run is True - def test_no_cron_string_by_default(self, task): - assert task.cron_string is None + def test_cron_string_uses_configured_schedule(self, task): + assert task.cron_string == mod.SCHEDULED_CLEANUP_ORPHANED_RESOURCES_CRON - def test_cron_string_set_when_schedule_enabled(self): - with patch.object(mod, "ENABLE_SCHEDULED_CLEANUP_ORPHANED_RESOURCES", True): - with patch.object( - mod, "SCHEDULED_CLEANUP_ORPHANED_RESOURCES_CRON", "0 5 * * *" - ): - assert CleanupOrphanedResourcesTask().cron_string == "0 5 * * *" + def test_cron_string_follows_config_override(self): + with patch.object( + mod, "SCHEDULED_CLEANUP_ORPHANED_RESOURCES_CRON", "30 2 * * *" + ): + assert CleanupOrphanedResourcesTask().cron_string == "30 2 * * *" def test_init_unschedules_when_no_cron(self, task): + task.cron_string = None + with patch.object(task, "unschedule") as mock_unschedule: assert task.init() is None mock_unschedule.assert_called_once()