added tests

This commit is contained in:
2026-04-12 09:35:35 -03:00
parent 5c82703ebe
commit 4de44baf98
14 changed files with 1056 additions and 49 deletions

53
tests/test_scenarios.py Normal file
View File

@@ -0,0 +1,53 @@
"""Contract tests — scenario management."""
import pytest
from tests.base import ContractHelpers as H
from tests.endpoints import Endpoints as E
class TestListScenarios:
@pytest.mark.asyncio
async def test_returns_list(self, client):
res = await client.get(E.SCENARIOS)
H.assert_status(res, 200)
H.assert_is_list(res.json(), min_length=4)
@pytest.mark.asyncio
async def test_each_has_metadata(self, client):
data = (await client.get(E.SCENARIOS)).json()
for s in data:
H.assert_has_fields(s, "scenario_id", "name", "description", "hubs", "flight_count")
@pytest.mark.asyncio
async def test_known_scenarios_present(self, client):
ids = [s["scenario_id"] for s in (await client.get(E.SCENARIOS)).json()]
assert "normal_ops" in ids
assert "weather_disruption_ord" in ids
assert "maintenance_delay_sfo" in ids
assert "crew_swap_ewr" in ids
class TestActiveScenario:
@pytest.mark.asyncio
async def test_get_active(self, client):
res = await client.get(E.SCENARIO_ACTIVE)
H.assert_status(res, 200)
H.assert_has_fields(res.json(), "scenario_id", "name")
@pytest.mark.asyncio
async def test_switch_scenario(self, client):
res = await client.put(E.SCENARIO_ACTIVE, json={"scenario_id": "normal_ops"})
H.assert_status(res, 200)
assert res.json()["scenario_id"] == "normal_ops"
res = await client.get(E.SCENARIO_ACTIVE)
assert res.json()["scenario_id"] == "normal_ops"
await client.put(E.SCENARIO_ACTIVE, json={"scenario_id": "weather_disruption_ord"})
@pytest.mark.asyncio
async def test_switch_invalid(self, client):
res = await client.put(E.SCENARIO_ACTIVE, json={"scenario_id": "nonexistent"})
H.assert_status(res, 200)
assert "error" in res.json()