2bd10dbdee
* use create_test_flow where possible
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
* fix and add more tests
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
* remove unused websocket stuff
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
* Revert "remove unused websocket stuff"
This reverts commit fc05f80951
.
* keepdb for make test
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
* fix more
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
* add tests for notification transports
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
31 lines
1 KiB
Python
31 lines
1 KiB
Python
"""root tests"""
|
|
from base64 import b64encode
|
|
|
|
from django.conf import settings
|
|
from django.test import TestCase
|
|
from django.urls import reverse
|
|
|
|
|
|
class TestRoot(TestCase):
|
|
"""Test root application"""
|
|
|
|
def test_monitoring_error(self):
|
|
"""Test monitoring without any credentials"""
|
|
response = self.client.get(reverse("metrics"))
|
|
self.assertEqual(response.status_code, 401)
|
|
|
|
def test_monitoring_ok(self):
|
|
"""Test monitoring with credentials"""
|
|
creds = "Basic " + b64encode(f"monitor:{settings.SECRET_KEY}".encode()).decode("utf-8")
|
|
auth_headers = {"HTTP_AUTHORIZATION": creds}
|
|
response = self.client.get(reverse("metrics"), **auth_headers)
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
def test_monitoring_live(self):
|
|
"""Test LiveView"""
|
|
self.assertEqual(self.client.get(reverse("health-live")).status_code, 204)
|
|
|
|
def test_monitoring_ready(self):
|
|
"""Test ReadyView"""
|
|
self.assertEqual(self.client.get(reverse("health-ready")).status_code, 204)
|