部署:重写 deploy/README(凭据/备份/清单),compose 透传腾讯凭据,health 自报 OCR 状态
This commit is contained in:
+30
-1
@@ -19,7 +19,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent)) # tests/ 自己
|
||||
from _tmpdir import workdir as _workdir # noqa: E402
|
||||
|
||||
from backend import db as dbm # noqa: E402
|
||||
from backend import judging, scheduler # noqa: E402
|
||||
from backend import app, judging, scheduler # noqa: E402
|
||||
from backend import seed, services as svc # noqa: E402
|
||||
from backend.services import ApiError # noqa: E402
|
||||
|
||||
@@ -584,5 +584,34 @@ class DeletionGraceTest(unittest.TestCase):
|
||||
(self.gid,)).fetchone())
|
||||
|
||||
|
||||
class HealthOcrTest(unittest.TestCase):
|
||||
"""上线自查要能一眼看出 OCR 配没配、这个月用了几次。"""
|
||||
|
||||
def test_health_reports_ocr_state(self):
|
||||
tmp = _workdir("shared")
|
||||
tmp.mkdir(exist_ok=True)
|
||||
path = tmp / f"health_{id(self)}.db"
|
||||
conn = dbm.connect(path)
|
||||
dbm.init_db(conn)
|
||||
try:
|
||||
ctx = app.Ctx(conn=conn, method="GET", path="/api/health",
|
||||
query={}, body={}, headers={})
|
||||
d = app.health(ctx)
|
||||
finally:
|
||||
conn.close()
|
||||
for suffix in ("", "-wal", "-shm"):
|
||||
f = Path(str(path) + suffix)
|
||||
if f.exists():
|
||||
try:
|
||||
f.unlink()
|
||||
except OSError:
|
||||
pass
|
||||
self.assertIn("ocr", d)
|
||||
self.assertIn("configured", d["ocr"]) # 只暴露「有没有」,不暴露密钥
|
||||
self.assertIn("mode", d["ocr"])
|
||||
self.assertIsInstance(d["ocr"].get("used"), int)
|
||||
self.assertEqual(d["version"], "1.2.0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
|
||||
Reference in New Issue
Block a user