Files
VacatureRadar/tests/unit/test_health.py
T
Jens 7caea3a1ee
deploy / deploy (push) Canceled after 0s
demo mode
2026-07-27 23:38:37 +02:00

28 lines
795 B
Python

from __future__ import annotations
import pytest
from django.test import override_settings
from apps.core.health import readiness
pytestmark = pytest.mark.django_db
@override_settings(HEALTHCHECK_REQUIRE_CACHE=True)
def test_readiness_checks_database_and_shared_cache():
result = readiness()
assert result.ok is True
assert result.checks == {"database": "ok", "cache": "ok"}
@override_settings(HEALTHCHECK_REQUIRE_CACHE=True)
def test_readiness_reports_cache_failure(monkeypatch):
def fail_cache(*args, **kwargs):
raise ConnectionError
monkeypatch.setattr("apps.core.health.cache.set", fail_cache)
result = readiness()
assert result.ok is False
assert result.checks["database"] == "ok"
assert result.checks["cache"] == "error:ConnectionError"