|
4 | 4 |
|
5 | 5 | class HealthCheckTest(APITestCase): |
6 | 6 |
|
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) |
9 | 22 |
|
10 | | - def test_healthcheck(self): |
| 23 | + def test_healthcheck_readiness(self): |
11 | 24 | # GET and HEAD (no auth required) |
12 | | - resp = self.client.get(self.url) |
| 25 | + url = '/readiness' |
| 26 | + resp = self.client.get(url) |
13 | 27 | self.assertContains(resp, "OK", status_code=200) |
14 | 28 |
|
15 | | - resp = self.client.head(self.url) |
| 29 | + resp = self.client.head(url) |
16 | 30 | self.assertEqual(resp.status_code, 200) |
17 | 31 |
|
18 | | - def test_healthcheck_invalid(self): |
| 32 | + def test_healthcheck_readiness_invalid(self): |
| 33 | + url = '/readiness' |
19 | 34 | for method in ('put', 'post', 'patch', 'delete'): |
20 | | - resp = getattr(self.client, method)(self.url) |
| 35 | + resp = getattr(self.client, method)(url) |
21 | 36 | # method not allowed |
22 | 37 | self.assertEqual(resp.status_code, 405) |
0 commit comments