fix: 心跳倒计时按服务器剩余时间显示,服务重启后页面继续更新
This commit is contained in:
@@ -616,6 +616,33 @@ def test_assemble_reports_hours_refresh_countdown(monkeypatch) -> None:
|
||||
assert stopped["hours_refresh_in"] == 0
|
||||
|
||||
|
||||
def test_frames_carry_a_boot_id_so_pages_can_reset_after_restart() -> None:
|
||||
from euniv.study_control import stamp_frame
|
||||
|
||||
first = stamp_frame("u-boot", {})
|
||||
second = stamp_frame("u-boot", {})
|
||||
assert second["seq"] == first["seq"] + 1
|
||||
assert isinstance(first["boot"], str) and len(first["boot"]) == 16
|
||||
assert first["boot"] == second["boot"]
|
||||
|
||||
|
||||
def test_every_frame_carries_the_time_left_before_the_next_heartbeat(monkeypatch) -> None:
|
||||
import time
|
||||
|
||||
monkeypatch.setattr("euniv.autostudy.work_running", lambda _eid: True)
|
||||
account = _Start(1, 0, 0, 0)
|
||||
account.employee_id = "u-beat"
|
||||
clock = {"now": 1000.0}
|
||||
monkeypatch.setattr(time, "time", lambda: clock["now"])
|
||||
live = {"workers": [{"id": 1, "interval": 5, "heartbeat_at": 1005.4, "heartbeat_in": 5}]}
|
||||
assert assemble(account, live)["workers"][0]["heartbeat_in"] == 5
|
||||
clock["now"] = 1003.6
|
||||
assert assemble(account, live)["workers"][0]["heartbeat_in"] == 2
|
||||
clock["now"] = 1006.0
|
||||
assert assemble(account, live)["workers"][0]["heartbeat_in"] == 0
|
||||
assert live["workers"][0]["heartbeat_in"] == 5
|
||||
|
||||
|
||||
def test_hours_met_clears_started_without_pause() -> None:
|
||||
account = _Start(1, 0, 0, 0)
|
||||
start_now(account)
|
||||
|
||||
Reference in New Issue
Block a user