From 499f99113f69d77a2e313e0b978703eaf2b3a1bb Mon Sep 17 00:00:00 2001 From: beefcarver Date: Sat, 14 Nov 2026 09:34:53 -0500 Subject: [PATCH] test(header): assert every catalogue follows the palette gradient --- tests/test_bassdrive.py | 4 +++- tests/test_header.py | 35 +++++++++++++++++++++++++++++------ tests/test_providers.py | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/tests/test_bassdrive.py b/tests/test_bassdrive.py index 6440d4e..9d0e17d 100644 --- a/tests/test_bassdrive.py +++ b/tests/test_bassdrive.py @@ -255,7 +255,9 @@ def test_provider_describes_its_catalogue() -> None: assert provider.has_schedule is True assert provider.bandcamp is False assert len(provider.hero) == 3 - assert "bright_cyan" in "".join(provider.hero) + # the header paints the wordmark with the palette gradient + assert provider.hero_gradient is True + assert "[" not in "".join(provider.hero) assert provider.hero_lines == ( "BASSDRIVE", "WORLDWIDE DRUM & BASS", diff --git a/tests/test_header.py b/tests/test_header.py index 5dfbef8..409d2d4 100644 --- a/tests/test_header.py +++ b/tests/test_header.py @@ -6,6 +6,7 @@ import types import pytest from rich.cells import cell_len +from beefy_player.palettes import DEFAULT_PALETTE, PALETTES from beefy_player.providers import PROVIDERS from beefy_player.providers.somafm import SomaFMProvider from beefy_player.providers.wordmark import render @@ -71,6 +72,17 @@ def hero_styles(provider) -> list[str]: ] +def hero_colours(provider) -> set[str]: + """Palette names the header actually painted the hero glyphs with.""" + palette = set(PALETTES[DEFAULT_PALETTE]) + return { + colour + for style in hero_styles(provider) + for colour in palette + if style.endswith(f" {colour}") + } + + def test_the_i_and_t_have_thin_stems() -> None: """Two-pixel stems make an I look like an H and a T look like a block.""" assert render("I") == ("▀█▀", " █", "▄█▄") @@ -108,27 +120,38 @@ def test_every_catalogue_has_a_three_row_wordmark() -> None: assert provider.hero_lines, slug -def test_tilderadio_spells_its_own_name_in_the_default_colour() -> None: +def test_tilderadio_spells_its_own_name_in_the_palette_gradient() -> None: provider = PROVIDERS["tilderadio"] lines = render_header(143, height=len(provider.hero), provider=provider) assert len(lines) == 3 assert "TILDERADIO" in lines[0] # the wordmark assert "STREAMED BY / FOR USERS OF THE" in lines[1] assert "TILDEVERSE" in lines[2] - # no colour of its own: the art inherits the terminal foreground + # the art carries no colours; the header itself paints the gradient assert all("[" not in row for row in provider.hero) - assert not {"bright_cyan", "cyan"} & set(hero_styles(provider)) + assert provider.hero_gradient + assert len(hero_colours(provider)) > 1 assert all("SOMA" not in line for line in lines) -def test_bassdrive_spells_its_name_in_its_own_two_blues() -> None: +def test_bassdrive_spells_its_name_in_the_palette_gradient() -> None: provider = PROVIDERS["bassdrive"] lines = render_header(143, height=len(provider.hero), provider=provider) assert "BASSDRIVE" in lines[0] assert "WORLDWIDE DRUM & BASS" in lines[1] assert "LIVE SHOWS 24/7" in lines[2] - styles = hero_styles(provider) - assert "bright_cyan" in styles and "cyan" in styles + assert provider.hero_gradient + assert len(hero_colours(provider)) > 1 + # no stale markup leaks into the painted rows + assert all("[" not in line for line in lines) + + +@pytest.mark.parametrize("slug", sorted(PROVIDERS)) +def test_every_catalogue_paints_its_wordmark_with_the_palette(slug: str) -> None: + """Every hero follows the active palette, not a colour of its own.""" + provider = PROVIDERS[slug] + assert provider.hero_gradient, slug + assert len(hero_colours(provider)) > 1, slug def _fake(provider): diff --git a/tests/test_providers.py b/tests/test_providers.py index d004a70..7e81d9f 100644 --- a/tests/test_providers.py +++ b/tests/test_providers.py @@ -154,7 +154,7 @@ def test_tilderadio_replaces_the_station_list_with_a_schedule() -> None: provider = TilderadioProvider() assert provider.has_schedule is True # the SomaFM wordmark's slot now holds tilderadio's own art and motto - assert provider.hero and not provider.hero_gradient + assert provider.hero and provider.hero_gradient assert provider.hero_lines == ( "TILDERADIO", "STREAMED BY / FOR USERS OF THE",