4
4
import pytest
5
5
6
6
from zulipterminal .config .themes import (
7
- NEW_THEMES ,
8
7
REQUIRED_STYLES ,
9
8
THEMES ,
10
9
all_themes ,
11
10
complete_and_incomplete_themes ,
12
- generate_theme ,
13
11
parse_themefile ,
14
- theme_with_monochrome_added ,
15
12
)
16
13
17
14
20
17
"gruvbox_dark" ,
21
18
"zt_light" ,
22
19
"zt_blue" ,
23
- "gruvbox_dark24" ,
24
20
}
25
21
aliases_16_color = [
26
22
"default" ,
@@ -54,11 +50,11 @@ def test_all_themes():
54
50
theme
55
51
if theme in expected_complete_themes
56
52
else pytest .param (theme , marks = pytest .mark .xfail (reason = "incomplete" ))
57
- for theme in NEW_THEMES
53
+ for theme in THEMES
58
54
],
59
55
)
60
- def test_new_builtin_theme_completeness (theme_name ):
61
- theme = NEW_THEMES [theme_name ]
56
+ def test_builtin_theme_completeness (theme_name ):
57
+ theme = THEMES [theme_name ]
62
58
theme_styles = theme .STYLES
63
59
theme_colors = theme .Color
64
60
@@ -92,60 +88,6 @@ def test_new_builtin_theme_completeness(theme_name):
92
88
assert fg in theme_colors and bg in theme_colors
93
89
94
90
95
- # Check built-in themes are complete for quality-control purposes
96
- @pytest .mark .parametrize (
97
- "theme_name" ,
98
- [
99
- theme
100
- if theme in expected_complete_themes
101
- else pytest .param (theme , marks = pytest .mark .xfail (reason = "incomplete" ))
102
- for theme in THEMES
103
- ],
104
- )
105
- def test_builtin_theme_completeness (theme_name ):
106
- theme = THEMES [theme_name ]
107
- styles_in_theme = {style [0 ] for style in theme }
108
-
109
- assert len (styles_in_theme ) == len (REQUIRED_STYLES )
110
- assert all (required_style in styles_in_theme for required_style in REQUIRED_STYLES )
111
-
112
-
113
- @pytest .mark .parametrize (
114
- "theme_name, depth" ,
115
- [
116
- ("zt_dark" , 1 ),
117
- ("zt_dark" , 16 ),
118
- ("zt_dark" , 256 ),
119
- ("zt_light" , 16 ),
120
- ("zt_blue" , 16 ),
121
- ("gruvbox_dark" , 16 ),
122
- ("gruvbox_dark" , 256 ),
123
- ("gruvbox_dark24" , 2 ** 24 ),
124
- ("gruvbox_dark24" , 2 ** 24 ),
125
- ],
126
- )
127
- def test_migrated_themes (theme_name , depth ):
128
- def split_and_strip (style ):
129
- style = style .split ("," )
130
- style = [s .strip () for s in style ]
131
- return style
132
-
133
- old_theme = theme_with_monochrome_added (THEMES [theme_name ])
134
-
135
- new_theme = generate_theme (theme_name .replace ("24" , "" ), depth )
136
-
137
- for new_style , old_style in zip (new_theme , old_theme ):
138
- assert new_style [0 ] == old_style [0 ]
139
- if depth == 1 :
140
- assert new_style [3 ] == old_style [3 ]
141
- elif depth == 16 :
142
- assert split_and_strip (new_style [1 ]) == split_and_strip (old_style [1 ])
143
- assert split_and_strip (new_style [2 ]) == split_and_strip (old_style [2 ])
144
- else :
145
- assert split_and_strip (new_style [4 ]) == split_and_strip (old_style [4 ])
146
- assert split_and_strip (new_style [5 ]) == split_and_strip (old_style [5 ])
147
-
148
-
149
91
def test_complete_and_incomplete_themes ():
150
92
# These are sorted to ensure reproducibility
151
93
result = (
@@ -155,32 +97,6 @@ def test_complete_and_incomplete_themes():
155
97
assert result == complete_and_incomplete_themes ()
156
98
157
99
158
- @pytest .mark .parametrize (
159
- "theme, expected_new_theme, req_styles" ,
160
- [
161
- ([("a" , "another" )], [], {}),
162
- ([("a" , "another" )], [("a" , "another" )], {"a" : "" }),
163
- ([("a" , "fg" , "bg" )], [("a" , "fg" , "bg" , "x" )], {"a" : "x" }),
164
- ([("a" , "fg" , "bg" , "bold" )], [("a" , "fg" , "bg" , "x" )], {"a" : "x" }),
165
- (
166
- [("a" , "fg" , "bg" , "bold" , "h1" , "h2" )],
167
- [("a" , "fg" , "bg" , "x" , "h1" , "h2" )],
168
- {"a" : "x" },
169
- ),
170
- ],
171
- ids = [
172
- "incomplete_theme" ,
173
- "one_to_one" ,
174
- "16_color_add_mono" ,
175
- "16_color_mono_overwrite" ,
176
- "256_color" ,
177
- ],
178
- )
179
- def test_theme_with_monochrome_added (mocker , theme , expected_new_theme , req_styles ):
180
- mocker .patch .dict ("zulipterminal.config.themes.REQUIRED_STYLES" , req_styles )
181
- assert theme_with_monochrome_added (theme ) == expected_new_theme
182
-
183
-
184
100
@pytest .mark .parametrize (
185
101
"color_depth, expected_urwid_theme" ,
186
102
[
0 commit comments