fix: 会话失效时自动重新登录,管理端可改判断依据
This commit is contained in:
@@ -527,6 +527,8 @@ def test_check_skips_empty_credential_and_updates_saved_one(monkeypatch) -> None
|
||||
"hours_month",
|
||||
"study_active",
|
||||
"state",
|
||||
"message",
|
||||
"hours_met",
|
||||
}
|
||||
assert saved["has_credential"] is True
|
||||
assert saved["refresh_paused"] is False
|
||||
@@ -985,6 +987,29 @@ def test_admin_can_save_study_settings_in_one_request() -> None:
|
||||
assert one["proxy"] == "HTTP 9.9.9.9:8080"
|
||||
|
||||
|
||||
def test_admin_can_set_account_hours_source() -> None:
|
||||
_add_account("source-user")
|
||||
_add_account("other-user")
|
||||
api = _app()
|
||||
client = TestClient(api.app)
|
||||
assert client.post("/api/login", json={"employee_id": "admin", "password": INITIAL_PASSWORD}).status_code == 200
|
||||
saved = client.put(
|
||||
"/api/admin/users/study-settings",
|
||||
json={"employee_ids": ["source-user"], "hours_source": "history"},
|
||||
)
|
||||
assert saved.status_code == 200
|
||||
listed = client.get("/api/admin/users").json()
|
||||
one = next(item for item in listed if item["employee_id"] == "source-user")
|
||||
other = next(item for item in listed if item["employee_id"] == "other-user")
|
||||
assert one["hours_source"] == "history"
|
||||
assert other["hours_source"] == "api"
|
||||
bad = client.put(
|
||||
"/api/admin/users/study-settings",
|
||||
json={"employee_ids": ["source-user"], "hours_source": "other"},
|
||||
)
|
||||
assert bad.status_code == 400
|
||||
|
||||
|
||||
def test_admin_can_switch_hours_source() -> None:
|
||||
api = _app()
|
||||
client = TestClient(api.app)
|
||||
|
||||
Reference in New Issue
Block a user