archive
/
actioner
Archived
1
Fork 0

Add tests for healthcheck API

This commit is contained in:
Jake Howard 2019-02-16 21:53:45 +00:00
parent e6a27d7354
commit b4e091a995
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 35 additions and 0 deletions

View 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()

View 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
})