Skip to content

Commit 5b3af45

Browse files
committed
fix(tests): add missing tests for /readiness endpoint
1 parent 65b736f commit 5b3af45

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

rootfs/api/tests/test_healthcheck.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,34 @@
44

55
class HealthCheckTest(APITestCase):
66

7-
def setUp(self):
8-
self.url = '/healthz'
7+
def test_healthcheck_liveness(self):
8+
# GET and HEAD (no auth required)
9+
url = '/healthz'
10+
resp = self.client.get(url)
11+
self.assertContains(resp, "OK", status_code=200)
12+
13+
resp = self.client.head(url)
14+
self.assertEqual(resp.status_code, 200)
15+
16+
def test_healthcheck_liveness_invalid(self):
17+
url = '/healthz'
18+
for method in ('put', 'post', 'patch', 'delete'):
19+
resp = getattr(self.client, method)(url)
20+
# method not allowed
21+
self.assertEqual(resp.status_code, 405)
922

10-
def test_healthcheck(self):
23+
def test_healthcheck_readiness(self):
1124
# GET and HEAD (no auth required)
12-
resp = self.client.get(self.url)
25+
url = '/readiness'
26+
resp = self.client.get(url)
1327
self.assertContains(resp, "OK", status_code=200)
1428

15-
resp = self.client.head(self.url)
29+
resp = self.client.head(url)
1630
self.assertEqual(resp.status_code, 200)
1731

18-
def test_healthcheck_invalid(self):
32+
def test_healthcheck_readiness_invalid(self):
33+
url = '/readiness'
1934
for method in ('put', 'post', 'patch', 'delete'):
20-
resp = getattr(self.client, method)(self.url)
35+
resp = getattr(self.client, method)(url)
2136
# method not allowed
2237
self.assertEqual(resp.status_code, 405)

0 commit comments

Comments
 (0)