From 8d4bd5636b3e33cc3b873abc15e5b4176dd06cb2 Mon Sep 17 00:00:00 2001 From: L1nSn0w Date: Fri, 13 Feb 2026 15:01:32 +0800 Subject: [PATCH] refactor(tests): replace hardcoded wait time with constant for clarity - Introduced HEARTBEAT_WAIT_TIMEOUT_SECONDS constant to improve readability and maintainability of test code. - Updated test assertions to use the new constant instead of a hardcoded value. (cherry picked from commit 0d53743d83b03ae0e68fad143711ffa5f6354093) --- api/tests/unit_tests/commands/test_upgrade_db.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/tests/unit_tests/commands/test_upgrade_db.py b/api/tests/unit_tests/commands/test_upgrade_db.py index 7f5e0e00c7..d884477143 100644 --- a/api/tests/unit_tests/commands/test_upgrade_db.py +++ b/api/tests/unit_tests/commands/test_upgrade_db.py @@ -5,6 +5,8 @@ from unittest.mock import MagicMock import commands +HEARTBEAT_WAIT_TIMEOUT_SECONDS = 1.0 + def _install_fake_flask_migrate(monkeypatch, upgrade_impl) -> None: module = types.ModuleType("flask_migrate") @@ -104,7 +106,7 @@ def test_upgrade_db_renews_lock_during_migration(monkeypatch, capsys): lock.reacquire.side_effect = _reacquire def _upgrade(): - assert renewed.wait(1.0) + assert renewed.wait(HEARTBEAT_WAIT_TIMEOUT_SECONDS) _install_fake_flask_migrate(monkeypatch, _upgrade) @@ -132,7 +134,7 @@ def test_upgrade_db_ignores_reacquire_errors(monkeypatch, capsys): lock.reacquire.side_effect = _reacquire def _upgrade(): - assert attempted.wait(1.0) + assert attempted.wait(HEARTBEAT_WAIT_TIMEOUT_SECONDS) _install_fake_flask_migrate(monkeypatch, _upgrade)