Przeglądaj źródła

可视化:统一后端测试与静态检查配置

将 pytest 和 Ruff 配置集中到 pyproject.toml,显式加入 backend import path,补充健康检查测试和 Ruff 依赖,并忽略本地缓存与 macOS 元数据。
SamLee 12 godzin temu
rodzic
commit
be878d7794

+ 3 - 0
visualization/.gitignore

@@ -1,8 +1,11 @@
 .cache/*
 !.cache/.gitkeep
+.DS_Store
+**/.DS_Store
 backend/.venv/
 backend/**/__pycache__/
 backend/.pytest_cache/
+backend/.ruff_cache/
 frontend/.next/
 frontend/node_modules/
 frontend/coverage/

+ 15 - 0
visualization/backend/pyproject.toml

@@ -0,0 +1,15 @@
+[tool.pytest.ini_options]
+testpaths = ["tests"]
+addopts = "-q"
+pythonpath = ["."]
+
+[tool.ruff]
+line-length = 100
+target-version = "py39"
+
+[tool.ruff.lint]
+select = ["E", "F", "I", "UP", "B", "ASYNC", "RUF"]
+ignore = ["RUF001", "UP045"]
+
+[tool.ruff.lint.isort]
+known-first-party = ["app"]

+ 0 - 4
visualization/backend/pytest.ini

@@ -1,4 +0,0 @@
-[pytest]
-testpaths = tests
-addopts = -q
-

+ 1 - 1
visualization/backend/requirements.txt

@@ -2,5 +2,5 @@ fastapi==0.116.1
 httpx==0.28.1
 pydantic==2.11.7
 pytest==8.4.1
+ruff==0.15.22
 uvicorn==0.35.0
-

+ 13 - 0
visualization/backend/tests/test_health.py

@@ -0,0 +1,13 @@
+from fastapi.testclient import TestClient
+
+from app.main import app
+
+
+def test_health_reports_journey_service() -> None:
+    response = TestClient(app).get("/api/health")
+
+    assert response.status_code == 200
+    assert response.json() == {
+        "status": "ok",
+        "service": "script-build-journey",
+    }