mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 10:33:22 +01:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user