28 lines
899 B
Python
28 lines
899 B
Python
from django.core.cache import cache
|
|
from django.test import override_settings
|
|
|
|
from apps.core.services.automation import _runtime_heartbeat_state
|
|
from apps.core.tasks import RUNTIME_HEARTBEAT_KEY, record_runtime_heartbeat
|
|
|
|
|
|
@override_settings(CELERY_TASK_ALWAYS_EAGER=False)
|
|
def test_runtime_heartbeat_reports_real_worker_execution():
|
|
cache.delete(RUNTIME_HEARTBEAT_KEY)
|
|
assert _runtime_heartbeat_state()["healthy"] is False
|
|
|
|
timestamp = record_runtime_heartbeat()
|
|
|
|
state = _runtime_heartbeat_state()
|
|
assert cache.get(RUNTIME_HEARTBEAT_KEY) == timestamp
|
|
assert state["healthy"] is True
|
|
assert state["label"].startswith("Actief")
|
|
|
|
|
|
@override_settings(CELERY_TASK_ALWAYS_EAGER=True)
|
|
def test_runtime_heartbeat_is_honest_in_eager_mode():
|
|
assert _runtime_heartbeat_state() == {
|
|
"label": "Eager/lokaal",
|
|
"healthy": True,
|
|
"observed_at": None,
|
|
}
|