健康检查接口基本契约。
| 85 | |
| 86 | |
| 87 | class TestHealthEndpoint: |
| 88 | """健康检查接口基本契约。""" |
| 89 | |
| 90 | def test_status_200(self, client): |
| 91 | assert client.get("/api/health").status_code == 200 |
| 92 | |
| 93 | def test_success_true(self, client): |
| 94 | assert _json(client.get("/api/health"))["success"] is True |
| 95 | |
| 96 | def test_service_field_is_string(self, client): |
| 97 | data = _json(client.get("/api/health")) |
| 98 | assert "service" in data |
| 99 | assert isinstance(data["service"], str) |
| 100 | |
| 101 | def test_simulation_running_is_bool(self, client): |
| 102 | data = _json(client.get("/api/health")) |
| 103 | assert isinstance(data.get("simulation_running"), bool) |
| 104 | |
| 105 | def test_simulation_not_running_with_test_engine(self, client): |
| 106 | """注入 autostart=False 引擎时 simulation_running 应为 False。""" |
| 107 | assert _json(client.get("/api/health"))["simulation_running"] is False |
| 108 | |
| 109 | |
| 110 | # --------------------------------------------------------------------------- |
nothing calls this directly
no outgoing calls
no test coverage detected