From 28a33437614436a876268f63d7c2441ff6d944bc Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Fri, 7 Jul 2023 18:11:29 -0400 Subject: [PATCH] Added sanity check tests to ensure PALETTE and MONO_PALETTE match And fixed a bug uncovered by the above tests :) --- tests/test_constants.py | 15 +++++++++++++++ toot/tui/constants.py | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/test_constants.py diff --git a/tests/test_constants.py b/tests/test_constants.py new file mode 100644 index 0000000..60a15cf --- /dev/null +++ b/tests/test_constants.py @@ -0,0 +1,15 @@ +from toot.tui.constants import PALETTE, MONO_PALETTE + + +def test_palette(): + # for every entry in PALETTE, there must be + # a corresponding entry in MONO_PALETTE + for pal in PALETTE: + matches = [item for item in MONO_PALETTE if item[0] == pal[0]] + assert len(matches) > 0, f"{pal}, present in PALETTE, missing from MONO_PALETTE" + + # for every entry in MONO_PALETTE, there must be + # a corresponding entry in PALETTE + for pal in MONO_PALETTE: + matches = [item for item in PALETTE if item[0] == pal[0]] + assert len(matches) > 0, f"{pal}, present in MONO_PALETTE, missing from PALETTE" diff --git a/toot/tui/constants.py b/toot/tui/constants.py index 285fcf7..e672947 100644 --- a/toot/tui/constants.py +++ b/toot/tui/constants.py @@ -75,7 +75,6 @@ MONO_PALETTE = [ ('warning', 'white,bold', 'black'), # Functional - ('account', 'dark green', ''), ('hashtag_followed', 'white,bold', ''), ('hashtag', 'white,bold', ''), ('link', ',italics', ''),