import importlib import ricefx ROLES = {"base", "surface", "overlay", "muted", "subtle", "text", "love", "gold", "rose", "pine", "foam", "iris", "highlightLow", "highlightMed", "highlightHigh"} NEW_THEMES = ["tokyo-night", "gruvbox", "catppuccin-mocha", "nord", "dracula"] def test_new_themes_present_with_all_roles(): for name in NEW_THEMES: assert name in ricefx.ACCENTS, name assert ROLES <= set(ricefx.ACCENTS[name]), name def test_theme_tables_consistent(): for name in ricefx.ACCENTS: assert name in ricefx.RAMPS, name assert name in ricefx.RAMPS_SOLID, name assert name in ricefx.RAMPS_TEXT, name assert name in ricefx.BACKGROUNDS, name assert len(ricefx.RAMPS[name]) == 8 assert len(ricefx.RAMPS_SOLID[name]) == 8 def test_all_colors_are_rgb_tuples(): for name, acc in ricefx.ACCENTS.items(): for role, c in acc.items(): assert len(c) == 3 and all(0 <= v <= 255 for v in c), (name, role) def _theme_with_env(monkeypatch, value): monkeypatch.setenv("RICEFX_THEME", value) monkeypatch.delenv("COLORFGBG", raising=False) importlib.reload(ricefx) return ricefx.theme() def test_theme_aliases_and_fallback(monkeypatch): assert _theme_with_env(monkeypatch, "rose-pine") == "dark" assert _theme_with_env(monkeypatch, "rose-pine-dawn") == "dawn" assert _theme_with_env(monkeypatch, "tokyo-night") == "tokyo-night" assert _theme_with_env(monkeypatch, "not-a-theme") == "dark" monkeypatch.delenv("RICEFX_THEME", raising=False) importlib.reload(ricefx) # leave module clean for other tests