Skip to content

Commit d95efda

Browse files
committed
theme: Add missing styles to REQUIRED_STYLES and check completeness.
* 3 missing styles: 'muted', 'current_user', 'table_head' were added to REQUIRED_STYLES. * `complete_and_incomplete_themes` was amended to check for equality instead of the superset criteria * The completeness test for builtin themes was added to check for equality with REQUIRED_STYLES and existance of Colors. * The FIXME in `generate_themes` that bypassed undefined styles in REQUIRED_STYLES removed.
1 parent a24c431 commit d95efda

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

tests/config/test_themes.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@ def test_all_themes():
2323
assert all_themes() == list(THEMES.keys())
2424

2525

26+
# Check built-in themes are complete for quality-control purposes
27+
@pytest.mark.parametrize(
28+
"theme_name",
29+
[
30+
theme
31+
if theme in expected_complete_themes
32+
else pytest.param(theme, marks=pytest.mark.xfail(reason="incomplete"))
33+
for theme in THEMES
34+
],
35+
)
36+
def test_builtin_theme_completeness(theme_name):
37+
theme = THEMES[theme_name]
38+
theme_styles = theme.STYLES
39+
theme_colors = theme.Color
40+
41+
assert len(theme_styles) == len(REQUIRED_STYLES)
42+
assert all(required_style in theme_styles for required_style in REQUIRED_STYLES)
43+
for style_name, style_conf in theme_styles.items():
44+
fg, bg = style_conf
45+
assert fg in theme_colors and bg in theme_colors
46+
47+
2648
def test_complete_and_incomplete_themes():
2749
# These are sorted to ensure reproducibility
2850
result = (

zulipterminal/config/themes.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def complete_and_incomplete_themes() -> Tuple[List[str], List[str]]:
3636
complete = {
3737
name
3838
for name, theme in THEMES.items()
39-
if {s for s in theme.STYLES}.issuperset(REQUIRED_STYLES)
39+
if theme.STYLES.keys() == REQUIRED_STYLES.keys()
4040
}
4141
incomplete = list(set(THEMES) - complete)
4242
return sorted(list(complete)), sorted(incomplete)
@@ -52,11 +52,7 @@ def generate_theme(theme_name: str, color_depth: int) -> ThemeSpec:
5252
bg_codes = bg.value.split()
5353
new_style: Tuple[Optional[str], ...] = tuple()
5454
if color_depth == 1:
55-
# FIXME: Check for completeness of REQUIRED_STYLES
56-
try:
57-
new_style = (style_name, "", "", REQUIRED_STYLES[style_name])
58-
except KeyError:
59-
continue
55+
new_style = (style_name, "", "", REQUIRED_STYLES[style_name])
6056
elif color_depth == 16:
6157
fg = " ".join([fg_codes[0]] + fg_codes[3:]).replace("_", " ")
6258
bg = " ".join([bg_codes[0]] + bg_codes[3:]).replace("_", " ")

zulipterminal/themes/_template.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ class Color(Enum):
104104
'popup_category' : 'bold',
105105
'unread_count' : 'bold',
106106
'starred_count' : '',
107+
'table_head' : 'bold',
107108
'filter_results' : 'bold',
108109
'edit_topic' : 'standout',
109110
'edit_tag' : 'standout',
110111
'edit_author' : 'bold',
111112
'edit_time' : 'bold',
113+
'current_user' : '',
114+
'muted' : 'bold',
112115
'popup_border' : 'bold',
113116
'area:help' : 'standout',
114117
'area:msg' : 'standout',

0 commit comments

Comments
 (0)