test(header): assert every catalogue follows the palette gradient

This commit is contained in:
beefcarver committed 2026-11-14 09:34:53 -05:00
1 parent 6aac4f4085
commit 499f99113f
3 files changed
+33 -8

No files matched your search

+3 -1
View File
@@ -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",
+29 -6
View File
@@ -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):
+1 -1
View File
@@ -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",