-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_healthz.py
More file actions
33 lines (24 loc) · 1.16 KB
/
test_healthz.py
File metadata and controls
33 lines (24 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from api.tests import DeisTestCase
class HealthCheckTest(DeisTestCase):
def test_healthcheck_liveness(self):
# GET and HEAD (no auth required)
response = self.client.get('/healthz')
self.assertContains(response, "OK", status_code=200)
response = self.client.head('/healthz')
self.assertEqual(response.status_code, 200)
def test_healthcheck_liveness_invalid(self):
for method in ('put', 'post', 'patch', 'delete'):
response = getattr(self.client, method)('/healthz')
# method not allowed
self.assertEqual(response.status_code, 405)
def test_healthcheck_readiness(self):
# GET and HEAD (no auth required)
response = self.client.get('/readiness')
self.assertContains(response, "OK", status_code=200)
response = self.client.head('/readiness')
self.assertEqual(response.status_code, 200)
def test_healthcheck_readiness_invalid(self):
for method in ('put', 'post', 'patch', 'delete'):
response = getattr(self.client, method)('/readiness')
# method not allowed
self.assertEqual(response.status_code, 405)