fix: 学时统一从我的学时页面按日期统计

This commit is contained in:
Nixevol
2026-11-19 02:44:04 +08:00
parent b9a332f791
commit a717ac714d
4 changed files with 159 additions and 99 deletions
+16 -3
View File
@@ -1155,9 +1155,9 @@ def test_home_and_history_hours_follow_source(monkeypatch) -> None:
history = client.get("/api/home/history")
assert home.json()["hours_source"] == history.json()["hours_source"] == "history"
assert home.json()["month_hours"] == history.json()["month_hours"] == 2
assert home.json()["year_hours"] == history.json()["year_hours"] == 2
assert home.json()["total_hours"] == history.json()["total_hours"] == 2
assert home.json()["today_hours"] == history.json()["today_hours"] == 0
assert home.json()["year_hours"] == history.json()["year_hours"] == "100"
assert home.json()["total_hours"] == history.json()["total_hours"] == "10"
assert home.json()["today_hours"] == history.json()["today_hours"] == 1
assert home.json()["total_score"] == "3.00"
@@ -1212,6 +1212,19 @@ def test_history_course_path_follows_type_and_keeps_explicit_url() -> None:
assert named["path"] == "/kng/view/package/abc.html"
def test_month_span_covers_the_whole_month() -> None:
from euniv.client import day_span, month_span, period_search_form
assert month_span(2026, 11) == ("2026-11-01", "2026-11-30")
assert month_span(2024, 2) == ("2024-02-01", "2024-02-29")
form = period_search_form("<input name='txtStartDate' value=''><input name='txtEndDate' value=''>", "2026-11-01", "2026-11-30")
assert form["txtStartDate"] == "2026-11-01"
assert form["txtEndDate"] == "2026-11-30"
assert form["btnSearch"] == "搜索"
assert form["ScriptManager1"] == "upList|btnSearch"
assert day_span(datetime(2026, 11, 19, 2, 10)) == ("2026-11-19", "2026-11-19")
def test_period_page_minutes_match_the_official_table() -> None:
from euniv.client import history_rows_from_page, period_cards