feat: 每月定时开始学习并改为本地计算心跳摘要
This commit is contained in:
@@ -447,6 +447,11 @@ def test_check_skips_empty_credential_and_updates_saved_one() -> None:
|
||||
"month_hours",
|
||||
"has_proxy",
|
||||
"proxy",
|
||||
"study_start",
|
||||
"study_start_day",
|
||||
"study_start_hour",
|
||||
"study_start_minute",
|
||||
"study_start_second",
|
||||
}
|
||||
assert saved["has_credential"] is True
|
||||
assert saved["refresh_paused"] is False
|
||||
@@ -690,3 +695,34 @@ def test_admin_can_set_and_clear_proxy_for_selected_users() -> None:
|
||||
detail = client.get("/api/admin/users/p1-user/proxy")
|
||||
assert detail.json()["has_password"] is False
|
||||
assert detail.json()["username"] == ""
|
||||
|
||||
|
||||
def test_admin_can_set_study_start_for_selected_users() -> None:
|
||||
_add_account("s1-user")
|
||||
_add_account("s2-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-start",
|
||||
json={"employee_ids": ["s1-user", "s2-user"], "day": 5, "hour": 16, "minute": 8, "second": 9},
|
||||
)
|
||||
assert saved.status_code == 200
|
||||
assert saved.json()["count"] == 2
|
||||
listed = client.get("/api/admin/users").json()
|
||||
one = next(item for item in listed if item["employee_id"] == "s1-user")
|
||||
two = next(item for item in listed if item["employee_id"] == "s2-user")
|
||||
assert one["study_start"] == "每月5日 16:08:09"
|
||||
assert two["study_start"] == "每月5日 16:08:09"
|
||||
one_only = client.put(
|
||||
"/api/admin/users/study-start",
|
||||
json={"employee_ids": ["s1-user"], "day": 20, "hour": 0, "minute": 0, "second": 0},
|
||||
)
|
||||
assert one_only.status_code == 200
|
||||
listed = client.get("/api/admin/users").json()
|
||||
one = next(item for item in listed if item["employee_id"] == "s1-user")
|
||||
two = next(item for item in listed if item["employee_id"] == "s2-user")
|
||||
assert one["study_start"] == "每月20日 00:00:00"
|
||||
assert two["study_start"] == "每月5日 16:08:09"
|
||||
detail = client.get("/api/admin/users/s1-user/study-start")
|
||||
assert detail.json()["day"] == 20
|
||||
|
||||
Reference in New Issue
Block a user