fix: 补上未进子任务的首页、课程筛选和客户端构造

This commit is contained in:
2026-11-16 11:54:10 +08:00
parent 86a7477fab
commit 0d7de2eac3
14 changed files with 185 additions and 136 deletions
+51
View File
@@ -100,5 +100,56 @@ def test_course_page_filters_by_title() -> None:
assert {item["name"] for item in filtered["kinds"]} == {"课程包", "文档"}
def test_uncategorized_filter_and_like_escape() -> None:
from euniv.courses import UNCATEGORIZED, course_page
from euniv.db import SessionLocal
from euniv.models import Course
with SessionLocal() as db:
db.add(Course(
path="/kng/view/document/plain.html",
title="100%完成",
kind="",
contributor="甲",
recommend="0",
learners="1",
released_on="2026-01-01",
updated_on="2026-01-01",
comments="0",
))
db.add(Course(
path="/kng/view/document/other.html",
title="axb",
kind="文档",
contributor="乙",
recommend="0",
learners="1",
released_on="2026-01-02",
updated_on="2026-01-02",
comments="0",
))
db.add(Course(
path="/kng/view/document/underscore.html",
title="a_b",
kind="文档",
contributor="丙",
recommend="0",
learners="1",
released_on="2026-01-03",
updated_on="2026-01-03",
comments="0",
))
db.commit()
blank = course_page(db, "", 0, 50, kind=UNCATEGORIZED)
assert blank["total"] == 1
assert blank["items"][0]["title"] == "100%完成"
kinds = {item["name"]: item["value"] for item in blank["kinds"]}
assert kinds["未分类"] == UNCATEGORIZED
found = course_page(db, "100%", 0, 50)
assert [item["title"] for item in found["items"]] == ["100%完成"]
underscore = course_page(db, "a_b", 0, 50)
assert [item["title"] for item in underscore["items"]] == ["a_b"]
def test_course_gap_stays_between_eight_and_sixteen_hours() -> None:
assert next_gap(_FixedRandom()) == timedelta(hours=12)