Spaces:
Sleeping
Sleeping
File size: 2,188 Bytes
6172160 4904e85 6172160 4904e85 6172160 4904e85 6172160 4904e85 6172160 4904e85 6172160 4904e85 6172160 4904e85 6172160 4904e85 6172160 4904e85 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | """Shared pytest fixtures for 911 dispatch supervisor test suite."""
from __future__ import annotations
import random
from typing import Any
import pytest
from src.city_schema import CitySchema
from src.models import (
Action,
DispatchAction,
IncidentSeverity,
IncidentStatus,
IncidentType,
UnitStatus,
UnitType,
)
@pytest.fixture
def seeded_random() -> random.Random:
"""Return a random.Random instance seeded with 42 for deterministic tests."""
return random.Random(42)
@pytest.fixture
def sample_unit_state() -> dict[str, Any]:
"""Return a minimal valid UnitState dict."""
return {
"unit_id": "MED-1",
"unit_type": UnitType.MEDIC,
"status": UnitStatus.AVAILABLE,
"location_x": 10.0,
"location_y": 10.0,
"assigned_incident_id": None,
"eta_seconds": 0.0,
"crew_count": 2,
}
@pytest.fixture
def sample_incident_state() -> dict[str, Any]:
"""Return a minimal valid IncidentState dict."""
return {
"incident_id": "INC-001",
"incident_type": IncidentType.CARDIAC_ARREST,
"severity": IncidentSeverity.PRIORITY_1,
"location_x": 12.0,
"location_y": 14.0,
"reported_at_step": 0,
"units_assigned": [],
"status": IncidentStatus.PENDING,
"survival_clock": 240.0,
}
@pytest.fixture
def sample_action() -> dict[str, Any]:
"""Return a minimal valid dispatch Action dict."""
return {
"action_type": DispatchAction.DISPATCH,
"unit_id": "MED-1",
"incident_id": "INC-001",
"notes": None,
"priority_override": None,
}
@pytest.fixture
def metro_city_schema() -> CitySchema:
"""Return a minimal valid CitySchema instance."""
return CitySchema(
city_name="Metro City",
grid_size=[100, 100],
districts=["downtown", "northside"],
units=[],
unit_speeds={
UnitType.MEDIC: 1.0,
UnitType.ENGINE: 0.8,
},
default_required_units={
IncidentType.CARDIAC_ARREST: [UnitType.MEDIC],
IncidentType.STRUCTURE_FIRE: [UnitType.ENGINE],
},
)
|