fix: 推送按序号只保留最新一帧,倒计时改用剩余秒数

This commit is contained in:
2026-11-16 09:38:07 +08:00
parent f20cf79e57
commit 556121a265
6 changed files with 57 additions and 30 deletions
-1
View File
@@ -97,7 +97,6 @@ def test_admin_login_succeeds_and_wrong_password_skips_euniv() -> None:
assert "euniv_admin_session" in client.cookies
assert COOKIE_NAME not in client.cookies
assert client.get("/api/session").json() == {"role": "admin", "username": "admin"}
assert client.get("/api/home").status_code == 403
assert client.get("/api/home/summary").status_code == 403
assert client.get("/api/home/exams").status_code == 403
assert client.get("/api/home/trainings").status_code == 403
+12 -6
View File
@@ -113,10 +113,18 @@ def test_login_stores_password_and_credential_only() -> None:
import euniv.api as api_module
import euniv.service as service_module
class RefreshingClient(FakeClient):
def home_summary(self) -> dict:
if self._token == "yxt-1":
self._token = "yxt-2"
return super().home_summary()
api_module.login_and_store = lambda db, employee_id, password, manual=False, auto_attempts=3: service_module.login_and_store(
db, employee_id, password, FakeClient, manual=manual, auto_attempts=auto_attempts
)
api_module.fetch_home = lambda db, employee_id: service_module.fetch_home(db, employee_id, FakeClient)
api_module.fetch_home_summary = lambda db, employee_id: service_module.fetch_home_summary(
db, employee_id, RefreshingClient
)
client = TestClient(api_module.app)
response = client.post("/api/login", json={"employee_id": "6650000146", "password": "secret-pass"})
assert response.status_code == 200
@@ -157,11 +165,9 @@ def test_login_stores_password_and_credential_only() -> None:
"password_login_at",
}
home = client.get("/api/home")
assert home.status_code == 200
body = home.json()
assert body["name"] == "测试用户"
assert body["exams"] == [{"name": "安全考试", "status": "已完成", "start": "2026-05-20 00:01:00"}]
summary = client.get("/api/home/summary")
assert summary.status_code == 200
assert summary.json()["name"] == "测试用户"
with SessionLocal() as db:
account = db.get(Account, "6650000146")
assert account is not None