fix: 已有数据库再次安装时接上原库而不是报错

This commit is contained in:
2026-10-30 10:31:08 +08:00
parent ea3391af76
commit 613ed3a8c7
5 changed files with 47 additions and 21 deletions
+15
View File
@@ -43,6 +43,21 @@ def client():
shutil.rmtree(TEST_DATA)
def test_install_again_uses_existing_database(client: TestClient):
from app.config import install_file
from app.db import reset_engine
install_file().unlink()
reset_engine()
again = client.post("/api/install", json={"sqlite": True, "adminUsername": "other", "adminPassword": "other-pass"})
assert again.status_code == 200
assert again.json()["already"] is True
logged = client.post("/api/auth/local", json={"username": "admin", "password": "admin-pass"})
assert logged.status_code == 200
rejected = client.post("/api/auth/local", json={"username": "other", "password": "other-pass"})
assert rejected.status_code == 400
def test_period_bounds():
assert check_period(1) == 1
assert check_period(31) == 31