fix: 学习任务跨月会停,失败的课不再记成已学完
This commit is contained in:
@@ -523,6 +523,14 @@ def test_assemble_prefers_live_month_hours() -> None:
|
||||
account.hours_month = "2026-10"
|
||||
account.month_hours = "88"
|
||||
assert assemble(account, {}, datetime(2026, 11, 2, tzinfo=CN_TZ))["month_hours"] == ""
|
||||
stale = assemble(
|
||||
account,
|
||||
{"state": "已达标", "month": "2026-10", "month_hours": "600", "message": "本月目标已达到"},
|
||||
datetime(2026, 11, 2, tzinfo=CN_TZ),
|
||||
)
|
||||
assert stale["state"] == ""
|
||||
assert stale["month_hours"] == ""
|
||||
assert stale["message"] == ""
|
||||
|
||||
|
||||
def test_schedule_disabled_skips_window_until_started() -> None:
|
||||
@@ -607,7 +615,9 @@ def test_finish_user_keeps_failure_and_clears_idle() -> None:
|
||||
_finish_user("u1")
|
||||
assert "u1" not in autostudy_status()["users"]
|
||||
_finish_user("u2", RuntimeError("boom"))
|
||||
assert autostudy_status()["users"]["u2"]["state"] == "学习失败"
|
||||
failed = autostudy_status()["users"]["u2"]
|
||||
assert failed["state"] == "学习失败"
|
||||
assert failed["message"] == "学习没有完成"
|
||||
_clear_user_status("u2")
|
||||
|
||||
|
||||
@@ -842,7 +852,9 @@ def test_video_interval_zero_still_sends_study_time(monkeypatch) -> None:
|
||||
user_stop = asyncio.Event()
|
||||
watcher = HoursWatcher(session, "u1", 600, user_stop)
|
||||
await _study_video(session, "kid", "", 0, global_stop, watcher, study_time=30)
|
||||
assert session.heartbeats == [(30, 30)]
|
||||
assert len(session.heartbeats) == 1
|
||||
assert session.heartbeats[0][0] == 30
|
||||
assert abs(session.heartbeats[0][1] - 30) <= 1
|
||||
|
||||
asyncio.run(main())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user