yksa-django-kit/tests/test_states.py
2026-08-17 22:50:10 +08:00

23 lines
883 B
Python

from __future__ import annotations
import pytest
from yksa_kit.choices import RunStatus
from yksa_kit.states import health_state
@pytest.mark.parametrize("status,expected", [
("success", "ok"), ("ok", "ok"), ("partial", "warning"), ("failed", "failed"),
("error", "failed"), ("running", "running"), ("pending", "running"),
("queued", "running"), ("skipped", "skipped"),
("", "unknown"), (None, "unknown"), ("something-new", "unknown"),
])
def test_domain_status_maps_to_one_vocabulary(status, expected):
assert health_state(status) == expected
@pytest.mark.parametrize("value", RunStatus.values)
def test_every_run_status_has_a_state(value):
"""A new RunStatus member without a mapping would render as `unknown` on every
status page, which reads as a bug in the poller rather than a missing table row."""
assert health_state(value) != "unknown"