Skip to content

Commit 91eaa4b

Browse files
committed
move health tests to test_health
1 parent 78907a8 commit 91eaa4b

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66

77
from 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)
2122
def 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)
3335
def 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)
4649
def 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)
6369
def test_health_check_returns_200_if_cache_is_never_stale(
6470
mocker: MockerFixture,
6571
client: TestClient,

tests/test_server.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
from edge_proxy.environments import EnvironmentService
1111

1212

13-
def test_liveness_check(client: TestClient) -> None:
14-
response = client.get("/proxy/health/liveness")
15-
assert response.status_code == 200
16-
17-
1813
def test_get_flags(
1914
mocker: MockerFixture,
2015
environment_1_feature_states_response_list: list[dict],

0 commit comments

Comments
 (0)