fix: 推送按序号只保留最新一帧,倒计时改用剩余秒数
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user