import httpx from fastapi.testclient import TestClient from app.main import app, get_pulp_client client = TestClient(app) class _FakeOnline: def status(self): return {"online": True} class _FakeDown: def status(self): raise httpx.ConnectError("connection refused") def test_healthz_online(): app.dependency_overrides[get_pulp_client] = lambda: _FakeOnline() try: resp = client.get("/healthz") finally: app.dependency_overrides.clear() assert resp.status_code == 200 assert "연결됨" in resp.text def test_healthz_offline_when_pulp_down(): app.dependency_overrides[get_pulp_client] = lambda: _FakeDown() try: resp = client.get("/healthz") finally: app.dependency_overrides.clear() assert resp.status_code == 503 assert "연결 실패" in resp.text