mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
|
|
"""Lock the persistence enum string values + members.
|
||
|
|
|
||
|
|
These enums are mirrored by Postgres enum types, embedded in stored DB
|
||
|
|
rows, and surfaced in the JSON API. Renaming a value (or removing a
|
||
|
|
member) silently breaks production data and previously-issued API
|
||
|
|
responses, so the strings + the set of members are the contract.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from app.automations.persistence.enums.automation_status import AutomationStatus
|
||
|
|
from app.automations.persistence.enums.run_status import RunStatus
|
||
|
|
from app.automations.persistence.enums.trigger_type import TriggerType
|
||
|
|
|
||
|
|
pytestmark = pytest.mark.unit
|
||
|
|
|
||
|
|
|
||
|
|
def test_automation_status_string_values_are_stable() -> None:
|
||
|
|
"""The exact strings persisted to Postgres and served in API JSON."""
|
||
|
|
assert {member.value for member in AutomationStatus} == {
|
||
|
|
"active",
|
||
|
|
"paused",
|
||
|
|
"archived",
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
def test_run_status_string_values_are_stable() -> None:
|
||
|
|
"""Run lifecycle states embedded in the ``automation_runs`` table."""
|
||
|
|
assert {member.value for member in RunStatus} == {
|
||
|
|
"pending",
|
||
|
|
"running",
|
||
|
|
"succeeded",
|
||
|
|
"failed",
|
||
|
|
"cancelled",
|
||
|
|
"timed_out",
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
def test_trigger_type_keeps_manual_member_even_though_unregistered() -> None:
|
||
|
|
"""``MANUAL`` is reserved (mirrors the Postgres enum) but the trigger
|
||
|
|
store does not register it in v1. The enum must keep both members so
|
||
|
|
existing DB rows and the schema migration plan stay valid."""
|
||
|
|
assert {member.value for member in TriggerType} == {"schedule", "manual"}
|