Skip to content

Commit

Permalink
theme: Add missing styles to REQUIRED_STYLES and check completeness.
Browse files Browse the repository at this point in the history
* 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 amended to check for
equality with REQUIRED_STYLES and existance of Colors.
  • Loading branch information
Rohitth007 committed Jun 12, 2021
1 parent 4dc9bdf commit a432d7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions tests/config/test_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
complete_and_incomplete_themes,
generate_theme,
)
from zulipterminal.themes import gruvbox, zt_blue, zt_dark, zt_light
from zulipterminal.themes._template import REQUIRED_STYLES


Expand All @@ -14,7 +15,6 @@
"gruvbox_dark",
"zt_light",
"zt_blue",
"gruvbox_dark24",
}


Expand All @@ -34,10 +34,14 @@ def test_all_themes():
)
def test_builtin_theme_completeness(theme_name):
theme = THEMES[theme_name]
styles_in_theme = {style[0] for style in theme}
theme_styles = theme.STYLES
theme_colors = theme.Color

assert len(styles_in_theme) >= len(REQUIRED_STYLES)
assert all(required_style in styles_in_theme for required_style in REQUIRED_STYLES)
assert len(theme_styles) == len(REQUIRED_STYLES)
assert all(required_style in theme_styles for required_style in REQUIRED_STYLES)
for style_name, style_conf in theme_styles.items():
fg, bg = style_conf
assert fg in theme_colors and bg in theme_colors


def test_complete_and_incomplete_themes():
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/config/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def complete_and_incomplete_themes() -> Tuple[List[str], List[str]]:
complete = {
name
for name, theme in THEMES.items()
if {s for s in theme.STYLES}.issuperset(REQUIRED_STYLES)
if theme.STYLES.keys() == REQUIRED_STYLES.keys()
}
incomplete = list(set(THEMES) - complete)
return sorted(list(complete)), sorted(incomplete)
Expand Down
3 changes: 3 additions & 0 deletions zulipterminal/themes/_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ class Color(Enum):
'popup_category' : 'bold',
'unread_count' : 'bold',
'starred_count' : '',
'table_head' : 'bold',
'filter_results' : 'bold',
'edit_topic' : 'standout',
'edit_tag' : 'standout',
'edit_author' : 'bold',
'edit_time' : 'bold',
'current_user' : '',
'muted' : 'bold',
'popup_border' : 'bold',
'area:help' : 'standout',
'area:msg' : 'standout',
Expand Down

0 comments on commit a432d7e

Please sign in to comment.