fix: 已学完的课不再重查,连续失败会退避

This commit is contained in:
2026-11-16 09:01:47 +08:00
parent f42633b5ad
commit 174d7a49e3
5 changed files with 160 additions and 13 deletions
+1
View File
@@ -31,6 +31,7 @@ def fresh_database():
connection.execute(text("DROP TABLE IF EXISTS course_sync"))
connection.execute(text("DROP TABLE IF EXISTS proxy_nodes"))
connection.execute(text("DROP TABLE IF EXISTS proxy_pool_sync"))
connection.execute(text("DROP TABLE IF EXISTS finished_courses"))
connection.execute(text("DROP TABLE IF EXISTS alembic_version"))
init_db()
ensure_admin_seed()
+46
View File
@@ -880,3 +880,49 @@ def test_document_uses_page_size_and_requeries_after_submit(monkeypatch) -> None
assert session.progress_calls == 2
asyncio.run(main())
def test_completed_course_skips_the_play_page(monkeypatch) -> None:
from euniv.autostudy import AutoStudyWorker
async def no_wait(*_args, **_kwargs) -> bool:
return False
monkeypatch.setattr("euniv.autostudy.wait_stop", no_wait)
monkeypatch.setattr("euniv.autostudy._remember_finished", lambda *_args, **_kwargs: None)
opened: list[str] = []
async def open_play(*_args, **_kwargs):
opened.append("opened")
return {}
monkeypatch.setattr("euniv.autostudy._open_play", open_play)
class DoneSession:
async def update_progress(self, _kid: str, _pkg: str) -> dict:
return {"studyschedule": 100, "status": "Completed"}
class Host:
_async_stop = asyncio.Event()
async def main() -> None:
watcher = HoursWatcher(DoneSession(), "u1", 600, asyncio.Event())
result = await AutoStudyWorker._study_one_course(
Host(),
DoneSession(),
"u1",
f"/kng/view/video/{COMPACT_KID}.html",
"已完成",
"视频",
{},
False,
watcher,
"",
"",
None,
set(),
)
assert result == "done"
assert opened == []
asyncio.run(main())