mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 19:47:12 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
The daily-limits phone app's launcher icon: charcoal #211D1B field, hourglass glyph in the shared accent #B8862E. Additive only, so every other app's icon is byte-identical. A registry invariant now refuses a new app that reuses another app's glyph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AcxgxMaQHMSGWzLRpNSkuP
85 lines
3.2 KiB
Python
85 lines
3.2 KiB
Python
"""Tests for the app registry, glyph library and family style invariants."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from python_pkg.app_icons import apps, glyphs, style
|
|
|
|
|
|
class TestGlyphLookup:
|
|
def test_known_glyph(self) -> None:
|
|
assert glyphs.get_glyph("barbell").name == "barbell"
|
|
|
|
def test_unknown_glyph_lists_alternatives(self) -> None:
|
|
with pytest.raises(KeyError, match="barbell"):
|
|
glyphs.get_glyph("nope")
|
|
|
|
|
|
class TestAppLookup:
|
|
def test_known_app(self) -> None:
|
|
assert apps.get_app("todo").glyph == "checklist"
|
|
|
|
def test_unknown_app_lists_alternatives(self) -> None:
|
|
with pytest.raises(KeyError, match="todo"):
|
|
apps.get_app("nope")
|
|
|
|
def test_asset_dir_is_under_repo(self) -> None:
|
|
app = apps.get_app("todo")
|
|
assert app.asset_dir == app.repo / "assets" / "icon"
|
|
|
|
|
|
class TestFamilyInvariants:
|
|
def test_every_app_references_a_real_glyph(self) -> None:
|
|
for app in apps.APPS.values():
|
|
assert app.glyph in glyphs.GLYPHS
|
|
|
|
def test_accents_are_shared(self) -> None:
|
|
"""Every app uses the one family accent; apps differ by glyph only."""
|
|
accents = {app.accent for app in apps.APPS.values()}
|
|
assert accents == {"#B8862E"}
|
|
|
|
def test_accents_are_hex_triplets(self) -> None:
|
|
for app in apps.APPS.values():
|
|
assert app.accent.startswith("#")
|
|
assert len(app.accent) == 7
|
|
int(app.accent[1:], 16)
|
|
|
|
def test_no_glyph_is_reused(self) -> None:
|
|
"""Apps are told apart by glyph; a new app must not borrow one."""
|
|
shared_by_design = {"track-bars"} # kuhylog + betting_sim, pre-existing
|
|
used = [app.glyph for app in apps.APPS.values()]
|
|
reused = {glyph for glyph in used if used.count(glyph) > 1}
|
|
assert reused <= shared_by_design
|
|
|
|
def test_safe_box_fits_inside_canvas(self) -> None:
|
|
assert style.SAFE_BOX < style.CANVAS
|
|
assert style.MIN_NEGATIVE_SPACE == style.STROKE_WIDTH / 2
|
|
|
|
def test_no_glyph_paints_the_background_colour(self) -> None:
|
|
"""A hole must be cut, not painted.
|
|
|
|
``icon_foreground`` and ``icon_monochrome`` are rendered on
|
|
transparency, so a shape filled with ``style.BACKGROUND`` to fake a
|
|
hole shows up as a charcoal blob on those layers instead of
|
|
disappearing — and on the monochrome layer, which the system
|
|
recolours, in the wrong colour entirely. Holes belong in the path as
|
|
``fill-rule="evenodd"`` subpaths.
|
|
"""
|
|
for glyph in glyphs.GLYPHS.values():
|
|
assert style.BACKGROUND.lower() not in glyph.body.lower(), (
|
|
f"{glyph.name} paints style.BACKGROUND; cut the hole with "
|
|
f'fill-rule="evenodd" instead'
|
|
)
|
|
|
|
|
|
class TestHourglassGlyph:
|
|
def test_daily_limits_uses_it(self) -> None:
|
|
assert apps.get_app("daily_limits").glyph == "hourglass"
|
|
|
|
def test_sand_is_filled_in_the_accent(self) -> None:
|
|
"""The sand takes the accent marker, so the monochrome layer recolours it."""
|
|
body = glyphs.get_glyph("hourglass").body
|
|
assert f'fill="{style.ACCENT_MARKER}"' in body
|
|
assert 'stroke="none"' in body
|