From d6cee184346872c7e3483e8e50ad5ab7de934619 Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 25 Nov 2026 10:30:30 +0300 Subject: [PATCH] test(vmbackups): the late-host test no longer leaves the clock frozen test_the_window_is_checked_again_after_the_host_answered started a second timezone.now patch inside started()'s and stopped it last, so it put started()'s frozen clock back for the tests after it: the worker's heartbeat test then saw no time pass. The host's answer now moves the clock started() set. --- vmbackups/tests/test_schedule.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vmbackups/tests/test_schedule.py b/vmbackups/tests/test_schedule.py index 62b2aa79..00b7e0c6 100644 --- a/vmbackups/tests/test_schedule.py +++ b/vmbackups/tests/test_schedule.py @@ -156,11 +156,11 @@ class ScheduleTests(TransactionTestCase): def test_the_window_is_checked_again_after_the_host_answered(self): self.pass_at(at(2026, 11, 17, 7, 59)) - # the host answers the checks only after the window ended - self.proxy.backup_plan.side_effect = lambda: patch_now.start() or { - "definition": "", "disks": [], "nvram": None, "left_out": []} - patch_now = patch("django.utils.timezone.now", return_value=at(2026, 11, 17, 8, 30)) - self.addCleanup(patch.stopall) + def answer_late(): # the host answers the checks only after the window ended + timezone.now.return_value = at(2026, 11, 17, 8, 30) # the clock started() set + return {"definition": "", "disks": [], "nvram": None, "left_out": []} + + self.proxy.backup_plan.side_effect = answer_late with self.assertRaisesMessage(OperationError, "window ended"): self.started(at(2026, 11, 17, 7, 59, 30), self.creates()[0]) self.assertFalse(Backup.objects.exists())