MCPcopy Create free account
hub / github.com/Tong89/smartNode / TestProbeEndpoints

Class TestProbeEndpoints

tests/test_api_integration.py:596–622  ·  view source on GitHub ↗

存活/就绪探针接口契约。

Source from the content-addressed store, hash-verified

594# ---------------------------------------------------------------------------
595
596class TestProbeEndpoints:
597 """存活/就绪探针接口契约。"""
598
599 def test_livez_returns_200(self, client):
600 resp = client.get("/api/livez")
601 assert resp.status_code == 200
602
603 def test_livez_response_has_status(self, client):
604 data = _json(client.get("/api/livez"))
605 assert data.get("status") == "alive"
606
607 def test_readyz_returns_non_200_when_not_running(self, client):
608 """引擎未运行时,就绪探针应返回非 200(503 或 500)。
609
610 注入 autostart=False 的引擎不持有 simulation_thread,
611 readyz 端点将因 AttributeError 返回 500,或因 running=False 返回 503。
612 两者均表明服务未就绪。
613 """
614 resp = client.get("/api/readyz")
615 assert resp.status_code in (503, 500), (
616 f"引擎未运行时 readyz 应返回 503 或 500,实际: {resp.status_code}"
617 )
618
619 def test_readyz_response_has_status_key(self, client):
620 """就绪探针响应应包含 status 或 code 字段(取决于是 503 还是 500 路径)。"""
621 data = _json(client.get("/api/readyz"))
622 assert "status" in data or "code" in data
623
624
625# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected