healthchecks_healthchecks/hc/api/tests/test_system_checks.py
Pēteris Caune 13f92b90ef
Update settings.py to read SECURE_PROXY_SSL_HEADER from env vars
And add it to docs.

And add a system check to make sure it, if set, is a tuple
with 2 elements.

cc: #851
2024-10-01 19:13:26 +03:00

25 lines
905 B
Python

from __future__ import annotations
from django.test.utils import override_settings
from hc.api.apps import settings_check
from hc.test import BaseTestCase
@override_settings(EMAIL_HOST="localhost")
class SystemChecksCase(BaseTestCase):
@override_settings(SITE_ROOT="example.com")
def test_it_validates_site_root(self) -> None:
ids = [item.id for item in settings_check(None, None)]
self.assertEqual(ids, ["hc.api.W001"])
@override_settings(EMAIL_HOST=None)
def test_it_warns_about_missing_smtp_credentials(self) -> None:
ids = [item.id for item in settings_check(None, None)]
self.assertEqual(ids, ["hc.api.W002"])
@override_settings(SECURE_PROXY_SSL_HEADER="abc")
def test_it_checks_secure_proxy_ssl_header_tupleness(self) -> None:
ids = [item.id for item in settings_check(None, None)]
self.assertEqual(ids, ["hc.api.W003"])