Files
uconsole_asw_game/tests/test_uboot_input_labels.py
Claude 86955542d4 uConsole boat: name every numeric entry in the input overlay
The overlay looked up "input.<mode>" and showed the raw key
(input.uboot_depth, input.uboot_course, ...) for all boat entries.
Adds the eight EN/DE labels and a regression test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdXs5tkJ6kzdeubNWqPHtG
2026-09-27 12:43:33 +00:00

36 lines
1.2 KiB
Python

"""The numeric-entry overlay names every boat entry in both languages
(it once showed the raw key ``input.uboot_depth``)."""
import json
from pathlib import Path
import pygame
from src.core import uboot_local
ROOT = Path(__file__).resolve().parents[1]
MODES = ("uboot_course", "uboot_speed", "uboot_depth", "uboot_bearing", "uboot_range",
"uboot_torpedo_depth", "uboot_wire_bearing", "uboot_wire_range")
def test_every_boat_entry_has_an_overlay_label():
for language in ("en", "de"):
catalog = json.loads((ROOT / "data" / "i18n" / f"{language}.json").read_text("utf-8"))
for mode in MODES:
assert catalog.get(f"input.{mode}"), (language, mode)
def test_overlay_shows_text_not_the_key(monkeypatch):
from test_uboot_scope import _local_boat
game, _boat = _local_boat()
shown = []
real = game.tr
monkeypatch.setattr(game, "tr", lambda key, **values: shown.append(real(key, **values))
or shown[-1])
for mode in ("uboot_course", "uboot_speed", "uboot_depth"):
uboot_local.begin_input(game, mode)
game.draw_navigation_input()
game.input_mode = None
assert shown and not any(text.startswith("input.") for text in shown)
pygame.event.clear()