Add tests for healthcheck API
This commit is contained in:
parent
e6a27d7354
commit
b4e091a995
2 changed files with 35 additions and 0 deletions
8
tests/test_web/__init__.py
Normal file
8
tests/test_web/__init__.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from aiohttp.test_utils import AioHTTPTestCase
|
||||
|
||||
from actioner.web import get_server
|
||||
|
||||
|
||||
class BaseWebTestCase(AioHTTPTestCase):
|
||||
async def get_application(self):
|
||||
return get_server()
|
27
tests/test_web/test_healthcheck.py
Normal file
27
tests/test_web/test_healthcheck.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from aiohttp import BasicAuth
|
||||
from aiohttp.test_utils import unittest_run_loop
|
||||
|
||||
from actioner.settings import BASIC_AUTH
|
||||
from tests.test_web import BaseWebTestCase
|
||||
|
||||
|
||||
class HealthcheckTestCase(BaseWebTestCase):
|
||||
@unittest_run_loop
|
||||
async def test_heartbeat_requires_auth(self):
|
||||
response = await self.client.get("/healthcheck")
|
||||
self.assertEqual(response.status, 401)
|
||||
response = await self.client.get("/healthcheck", headers={
|
||||
'Authorization': BasicAuth(*BASIC_AUTH).encode()
|
||||
})
|
||||
self.assertEqual(response.status, 200)
|
||||
|
||||
@unittest_run_loop
|
||||
async def test_heartbeat_response(self):
|
||||
response = await self.client.get("/healthcheck", headers={
|
||||
'Authorization': BasicAuth(*BASIC_AUTH).encode()
|
||||
})
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertEqual(await response.json(), {
|
||||
'github': 'RealOrangeOne',
|
||||
'todoist': 7471233
|
||||
})
|
Reference in a new issue