健康检查接口契约。
| 75 | # --------------------------------------------------------------------------- |
| 76 | |
| 77 | class TestHealthEndpoint: |
| 78 | """健康检查接口契约。""" |
| 79 | |
| 80 | def test_returns_200(self, client): |
| 81 | resp = client.get("/api/health") |
| 82 | assert resp.status_code == 200 |
| 83 | |
| 84 | def test_response_contains_success(self, client): |
| 85 | data = _json(client.get("/api/health")) |
| 86 | assert data.get("success") is True |
| 87 | |
| 88 | def test_response_contains_service(self, client): |
| 89 | data = _json(client.get("/api/health")) |
| 90 | assert "service" in data |
| 91 | assert isinstance(data["service"], str) |
| 92 | |
| 93 | def test_response_contains_simulation_running(self, client): |
| 94 | data = _json(client.get("/api/health")) |
| 95 | assert "simulation_running" in data |
| 96 | assert isinstance(data["simulation_running"], bool) |
| 97 | |
| 98 | def test_simulation_running_is_false(self, client): |
| 99 | """注入 autostart=False 的引擎时,simulation_running 应为 False。""" |
| 100 | data = _json(client.get("/api/health")) |
| 101 | assert data["simulation_running"] is False |
| 102 | |
| 103 | |
| 104 | # --------------------------------------------------------------------------- |
nothing calls this directly
no outgoing calls
no test coverage detected