Files
uconsole_asw_game/tests/test_station_page_metadata.py
T
Claude 5bf595d336 OPZ: richer chart and a Display page of settings (1.3.169)
Page 5 (Display) sets track trails, vector length, labels, a bearing
scale with the own course, range rings, bearing lines, furthest-on
circles, depths and grid, radar afterglow and the selected track's CPA.
Arrow keys or clicks set them, chips under the chart switch layers on
every page, and settings.json keeps them. The browser OPZ gets the same
buttons and drawing (trails from the chart history in the projection).
Display only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TjEy6GJs4wG9N9DMGGNA9X
2026-10-03 05:02:44 +00:00

98 lines
3.4 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", "OPZ_GROUP",
"OPZ_DISPLAY")
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
5 if station is Station.OPZ else
4 if station is Station.HELICOPTER else
3 if station in (Station.BRIDGE, Station.RADIO, Station.DAMAGE)
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))
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_opz_display_page_wraps():
assert station_page_step(Station.OPZ, 2, 1) == 3
assert station_page_step(Station.OPZ, 3, 1) == 4
assert station_page_step(Station.OPZ, 4, 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, 4, 1) == 0
def test_station_page_step_rejects_unknown_stations():
with pytest.raises(KeyError):
station_page_step("SONAR", 0, 1)