fix: 补上清单里还没对上的登录拒绝、会话回退和代理清理

This commit is contained in:
2026-11-16 16:46:37 +08:00
parent a1e2b6e65c
commit 3cff9dc37a
19 changed files with 223 additions and 65 deletions
+4 -2
View File
@@ -382,7 +382,9 @@ class _Dead:
return False
def login(self, manual: bool = False, auto_attempts: int = 3) -> dict:
raise RuntimeError("登录失败:密码错误")
from euniv.client import LoginRejected
raise LoginRejected("账号或密码错误")
def test_refresh_records_outcome_and_skips_paused_accounts() -> None:
@@ -417,7 +419,7 @@ def test_refresh_records_outcome_and_skips_paused_accounts() -> None:
assert failed.credential_valid is False
assert failed.last_refresh_at is not None
assert decrypt_secret(failed.password_cipher) == "secret-pass"
assert json.loads(decrypt_secret(failed.credential_cipher))["yxt_token"] == "yxt-1"
assert failed.credential_cipher == ""
assert paused.last_refresh_at == stamped.replace(tzinfo=None) or paused.last_refresh_at == stamped
assert paused.credential_valid is True
assert empty.credential_valid is False
+13 -2
View File
@@ -249,14 +249,14 @@ def test_accumulate_month_minutes_stops_at_previous_month() -> None:
calls.append((offset, limit))
return pages[offset // limit]
assert accumulate_month_minutes(fetch, 2026, 11, page_size=2) == 35
assert accumulate_month_minutes(fetch, 2026, 11, page_size=2) == (35, False)
assert calls == [(0, 2), (2, 2)]
dumped = [
{"title": "a", "minutes": 8, "studied_at": "2026-11-14 10:00:00"},
{"title": "b", "minutes": 4, "studied_at": "2026-10-30 10:00:00"},
]
assert fold_month_minutes(dumped, 2026, 11) == (8, True)
assert accumulate_month_minutes(lambda _offset, _limit: dumped, 2026, 11, page_size=100) == 8
assert accumulate_month_minutes(lambda _offset, _limit: dumped, 2026, 11, page_size=100) == (8, False)
def test_history_hour_totals_splits_year_month_today() -> None:
@@ -519,6 +519,17 @@ def test_interval_plan_manual_one_second_uses_admin_wait() -> None:
assert page == 1
def test_wanted_account_without_credential_is_dropped() -> None:
from euniv.autostudy import AutoStudyWorker, is_wanted, want_work
want_work("missing-user")
AutoStudyWorker()._collect()
assert is_wanted("missing-user") is False
info = autostudy_status()["users"]["missing-user"]
assert info["message"] == "登录凭证待校验"
assert info["state"] == "学习失败"
def test_assemble_prefers_live_month_hours() -> None:
account = _Start(1, 0, 0, 0)
account.month_hours = "10"