66
77from edge_proxy .settings import HealthCheckSettings
88
9- pytestmark = [
10- pytest .mark .parametrize (
11- "endpoint" ,
12- [
13- "/proxy/health/readiness" ,
14- "/proxy/health" ,
15- "/health" ,
16- ],
17- )
9+ READINESS_ENDPOINTS = [
10+ "/proxy/health/readiness" ,
11+ "/proxy/health" ,
12+ "/health" ,
1813]
1914
2015
16+ def test_liveness_check (client : TestClient ) -> None :
17+ response = client .get ("/proxy/health/liveness" )
18+ assert response .status_code == 200
19+
20+
21+ @pytest .mark .parametrize ("endpoint" , READINESS_ENDPOINTS )
2122def test_health_check_returns_200_if_cache_was_updated_recently (
2223 mocker : MockerFixture ,
2324 client : TestClient ,
@@ -30,6 +31,7 @@ def test_health_check_returns_200_if_cache_was_updated_recently(
3031 assert response .status_code == 200
3132
3233
34+ @pytest .mark .parametrize ("endpoint" , READINESS_ENDPOINTS )
3335def test_health_check_returns_503_if_cache_was_not_updated (
3436 client : TestClient ,
3537 endpoint : str ,
@@ -43,6 +45,7 @@ def test_health_check_returns_503_if_cache_was_not_updated(
4345 }
4446
4547
48+ @pytest .mark .parametrize ("endpoint" , READINESS_ENDPOINTS )
4649def test_health_check_returns_503_if_cache_is_stale (
4750 mocker : MockerFixture ,
4851 client : TestClient ,
@@ -51,7 +54,9 @@ def test_health_check_returns_503_if_cache_is_stale(
5154 last_updated_at = datetime .now () - timedelta (days = 10 )
5255 mocked_environment_service = mocker .patch ("edge_proxy.server.environment_service" )
5356 mocked_environment_service .last_updated_at = last_updated_at
57+
5458 response = client .get (endpoint )
59+
5560 assert response .status_code == 503
5661 assert response .json () == {
5762 "status" : "error" ,
@@ -60,6 +65,7 @@ def test_health_check_returns_503_if_cache_is_stale(
6065 }
6166
6267
68+ @pytest .mark .parametrize ("endpoint" , READINESS_ENDPOINTS )
6369def test_health_check_returns_200_if_cache_is_never_stale (
6470 mocker : MockerFixture ,
6571 client : TestClient ,
0 commit comments