feat: 新账号默认不开定时启动,首次登录不自动学习
This commit is contained in:
@@ -727,7 +727,7 @@ def test_user_can_set_monthly_study_start(monkeypatch) -> None:
|
||||
"hour": 0,
|
||||
"minute": 0,
|
||||
"second": 0,
|
||||
"enabled": True,
|
||||
"enabled": False,
|
||||
"label": "每月8日 00:00:00",
|
||||
}
|
||||
saved = client.put("/api/settings/study-start", json={"day": 5, "hour": 16, "minute": 0, "second": 7, "enabled": False})
|
||||
@@ -755,6 +755,32 @@ def _freeze_beijing(monkeypatch, year: int, month: int, day: int) -> None:
|
||||
monkeypatch.setattr("euniv.study_window.as_cn", frozen)
|
||||
|
||||
|
||||
def test_new_account_does_not_study_until_the_user_asks(monkeypatch) -> None:
|
||||
import euniv.api as api_module
|
||||
import euniv.service as service_module
|
||||
from euniv.autostudy import work_running
|
||||
|
||||
monkeypatch.setattr(
|
||||
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)
|
||||
_freeze_beijing(monkeypatch, 2026, 11, 15)
|
||||
assert client.post("/api/login", json={"employee_id": "6650000146", "password": "secret-pass"}).status_code == 200
|
||||
first = client.get("/api/settings/study-control").json()
|
||||
assert first["window_open"] is True
|
||||
assert first["schedule_enabled"] is False
|
||||
assert first["started"] is False
|
||||
assert first["active"] is False
|
||||
assert work_running("6650000146") is False
|
||||
client.put("/api/settings/study-start", json={"day": 8, "hour": 0, "minute": 0, "second": 0, "enabled": True})
|
||||
assert work_running("6650000146") is True
|
||||
assert client.get("/api/settings/study-control").json()["started"] is True
|
||||
|
||||
|
||||
def test_user_can_start_and_stop_study_immediately(monkeypatch) -> None:
|
||||
import euniv.api as api_module
|
||||
import euniv.service as service_module
|
||||
|
||||
Reference in New Issue
Block a user