skywalker-1/tui/tests/test_splash.py
Ryan Malloy 6dcb6b693a Add radar scope, splash screen, Star Wars easter egg, and harden TUI
New features:
- P1 green phosphor radar scope widget on Track screen with LUT-optimized rendering
- Splash screen with pre-baked ANSI half-block art from 16colo.rs/Mistigris
- Star Wars ASCII animation via telnet (ctrl+w) with IPv6 happy eyeballs and offline fallback
- Dark Side / New Hope toast notifications on theme toggle
- Kitty terminal detection with cat emoji on splash

Robustness (from Apollo code review):
- Circuit breaker in track loop after 10 consecutive errors
- Input validation for frequency, symbol rate, step size across scan/spectrum/track
- Consolidated sys.path manipulation into __init__.py
- Radar scope pre-computes dist/angle LUT per pixel on resize

Cleanup:
- Removed unused imports across lband, monitor, scan, signal_gauge
- Moved Pillow/textual-image to optional dev deps (splash uses pre-baked ANSI)
- Added 41-test pytest suite covering telnet IAC parsing, radar geometry, splash assets
2026-02-14 09:51:58 -07:00

49 lines
1.8 KiB
Python

"""Tests for the splash screen art catalog and selection."""
from skywalker_tui.screens.splash import SplashScreen, ASSETS_DIR, ART_CATALOG
class TestSplashArtCatalog:
"""Verify bundled pre-baked .ans art assets exist and catalog is consistent."""
def test_assets_dir_exists(self):
assert ASSETS_DIR.is_dir(), f"Assets dir missing: {ASSETS_DIR}"
def test_all_catalog_entries_have_ans_files(self):
missing = []
for stem, artist, title in ART_CATALOG:
path = ASSETS_DIR / f"{stem}.ans"
if not path.exists():
missing.append(f"{stem}.ans")
assert not missing, f"Missing pre-baked .ans files: {missing}"
def test_catalog_has_entries(self):
assert len(ART_CATALOG) >= 1
def test_ans_files_not_empty(self):
for stem, _, _ in ART_CATALOG:
path = ASSETS_DIR / f"{stem}.ans"
if path.exists():
assert path.stat().st_size > 0, f"{stem}.ans is empty"
def test_ans_files_contain_ansi_escapes(self):
"""Pre-baked files should contain ANSI color escape sequences."""
for stem, _, _ in ART_CATALOG:
path = ASSETS_DIR / f"{stem}.ans"
if path.exists():
content = path.read_text()
assert "\033[" in content, f"{stem}.ans has no ANSI escapes"
assert "\u2580" in content, f"{stem}.ans has no half-block chars"
class TestSplashScreenInit:
"""Test SplashScreen construction (no app needed)."""
def test_selects_art_on_init(self):
screen = SplashScreen()
assert screen._ans_path is not None or len(ART_CATALOG) == 0
if screen._ans_path:
assert screen._ans_path.exists()
assert screen._artist != ""
assert screen._title != ""