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)
This commit is contained in:
L1nSn0w
2026-02-13 15:01:32 +08:00
parent ee0c4a8852
commit 8d4bd5636b

View File

@@ -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)