feat: 账号可设置同时学习课程数并支持关闭代理
This commit is contained in:
@@ -121,6 +121,7 @@ def test_login_stores_password_and_credential_only() -> None:
|
||||
"study_start_hour",
|
||||
"study_start_minute",
|
||||
"study_start_second",
|
||||
"course_workers",
|
||||
}
|
||||
|
||||
home = client.get("/api/home")
|
||||
@@ -456,6 +457,7 @@ def test_user_can_set_proxy_with_or_without_password() -> None:
|
||||
empty = client.get("/api/settings/proxy")
|
||||
assert empty.status_code == 200
|
||||
assert empty.json()["enabled"] is False
|
||||
assert empty.json()["scheme"] == "off"
|
||||
assert "password" not in empty.json()
|
||||
saved = client.put(
|
||||
"/api/settings/proxy",
|
||||
@@ -490,6 +492,30 @@ def test_user_can_set_proxy_with_or_without_password() -> None:
|
||||
cleared = client.delete("/api/settings/proxy")
|
||||
assert cleared.status_code == 200
|
||||
assert cleared.json()["enabled"] is False
|
||||
assert cleared.json()["scheme"] == "off"
|
||||
off = client.put("/api/settings/proxy", json={"scheme": "off"})
|
||||
assert off.status_code == 200
|
||||
assert off.json()["enabled"] is False
|
||||
assert off.json()["scheme"] == "off"
|
||||
|
||||
|
||||
def test_user_can_set_course_workers() -> None:
|
||||
import euniv.api as api_module
|
||||
import euniv.service as service_module
|
||||
|
||||
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
|
||||
)
|
||||
client = TestClient(api_module.app)
|
||||
assert client.post("/api/login", json={"employee_id": "6650000146", "password": "secret-pass"}).status_code == 200
|
||||
empty = client.get("/api/settings/course-workers")
|
||||
assert empty.status_code == 200
|
||||
assert empty.json() == {"workers": 1, "max": 8, "recommended": True}
|
||||
saved = client.put("/api/settings/course-workers", json={"workers": 3})
|
||||
assert saved.status_code == 200
|
||||
assert saved.json() == {"workers": 3, "max": 8, "recommended": False}
|
||||
bad = client.put("/api/settings/course-workers", json={"workers": 9})
|
||||
assert bad.status_code == 400
|
||||
|
||||
|
||||
def test_user_can_set_monthly_study_start() -> None:
|
||||
|
||||
Reference in New Issue
Block a user