This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
actioner/tests/test_web/test_healthcheck.py

27 lines
947 B
Python
Raw Normal View History

2019-02-16 21:53:45 +00:00
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)
2019-02-22 22:36:17 +00:00
response = await self.client.get(
"/healthcheck", headers={"Authorization": BasicAuth(*BASIC_AUTH).encode()}
)
2019-02-16 21:53:45 +00:00
self.assertEqual(response.status, 200)
@unittest_run_loop
async def test_heartbeat_response(self):
2019-02-22 22:36:17 +00:00
response = await self.client.get(
"/healthcheck", headers={"Authorization": BasicAuth(*BASIC_AUTH).encode()}
)
2019-02-16 21:53:45 +00:00
self.assertEqual(response.status, 200)
2019-02-22 22:36:17 +00:00
self.assertEqual(
await response.json(), {"github": "RealOrangeOne", "todoist": 7471233}
)