Files
uconsole_asw_game/tests/test_station_page_metadata.py
T
Claude 631a284f9e Add the on-call maritime patrol aircraft (OPZ page 3)
A patrol aircraft from the nearest friendly airfield: the OPZ requests it,
sets its search area (selected track or chart click), plans buoy patterns,
drops buoys, switches its surface-search radar and releases a torpedo on the
designated contact. It reports only by datalink: RADAR-MPA tracks and its
buoys while it relays them. Remote Crew OPZ gets the same orders; save v21
adds the aircraft and each buoy's owner.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019eZphdvoJiBgWqq2zSH4aJ
2026-09-27 19:20:17 +00:00

90 lines
3.1 KiB
Python

import pytest
from src.core.commands import STATION_PAGES, station_page_step
from src.core.station import Station
SONAR_PAGES = (
"BROADBAND",
"LOFAR",
"DEMON",
"TMA",
"UMWELT/FUSION",
"ACTIVE",
)
TWO_PAGE_STATIONS = {
Station.WEAPONS: ("WEAPONS_TARGET", "WEAPONS_AMMO"),
Station.ENGINE: ("ENGINE_TELEGRAPH", "ENGINE_SYSTEMS"),
Station.ELOKA: ("ELOKA_INTERCEPTS", "ELOKA_EVIDENCE"),
}
def test_page_metadata_covers_every_canonical_station():
assert set(STATION_PAGES) == set(Station)
assert STATION_PAGES[Station.SONAR] == SONAR_PAGES
assert STATION_PAGES[Station.HELICOPTER] == ("HELO_STATUS", "HELO_MISSION", "HELO_SONAR", "HELO_ACOUSTIC")
assert STATION_PAGES[Station.BRIDGE] == ("BRIDGE_NAV", "BRIDGE_MISSION", "BRIDGE_LOOKOUT")
assert STATION_PAGES[Station.RADIO] == ("RADIO_HFDF", "RADIO_MESSAGES", "RADIO_TASKS")
assert STATION_PAGES[Station.DAMAGE] == ("DAMAGE_PLAN", "DAMAGE_DETAIL", "DAMAGE_CREW")
assert STATION_PAGES[Station.OPZ] == ("OPZ_PICTURE", "OPZ_TARGET", "OPZ_MPA")
for station, pages in TWO_PAGE_STATIONS.items():
assert STATION_PAGES[station] == pages
for station in Station:
pages = STATION_PAGES[station]
assert isinstance(pages, tuple)
assert pages
assert all(isinstance(page, str) and page for page in pages)
assert len(pages) == (6 if station is Station.SONAR else
4 if station is Station.HELICOPTER else
3 if station in (Station.BRIDGE, Station.RADIO, Station.DAMAGE,
Station.OPZ) else 2)
def test_helicopter_sonar_page_wraps():
assert station_page_step(Station.HELICOPTER, 1, 1) == 2
assert station_page_step(Station.HELICOPTER, 2, 1) == 3
assert station_page_step(Station.HELICOPTER, 3, 1) == 0
@pytest.mark.parametrize(
("current", "delta", "expected"),
[
(0, 1, 1),
(5, 1, 0),
(0, -1, 5),
(1, 13, 2),
(1, -14, 5),
("4", "1", 5),
],
)
def test_station_page_step_wraps_in_both_directions(current, delta, expected):
assert station_page_step(Station.SONAR, current, delta) == expected
@pytest.mark.parametrize("station", list(TWO_PAGE_STATIONS))
def test_two_page_stations_wrap_within_two_pages(station):
assert station_page_step(station, 0, 1) == 1
assert station_page_step(station, 1, 1) == 0
assert station_page_step(station, 5, 1) == 0
assert station_page_step(station, 2, -1) == 1
assert station_page_step(station, 0, -1) == 1
@pytest.mark.parametrize("station", (Station.RADIO, Station.DAMAGE, Station.OPZ))
def test_three_page_stations_wrap(station):
assert station_page_step(station, 1, 1) == 2
assert station_page_step(station, 2, 1) == 0
def test_station_alias_uses_canonical_opz_metadata():
assert Station.RADAR is Station.OPZ
assert STATION_PAGES[Station.RADAR] == STATION_PAGES[Station.OPZ]
assert station_page_step(Station.RADAR, 2, 1) == 0
def test_station_page_step_rejects_unknown_stations():
with pytest.raises(KeyError):
station_page_step("SONAR", 0, 1)