@@ -27,6 +27,7 @@ def setUp(self):
27
27
self .config_legacy = {"menu_theme" : "legacy" } # Legacy theme
28
28
self .config_none = {"menu_theme" : "none" } # Alternate colorless theme alias
29
29
30
+ # Test cases for default theme
30
31
@patch ("builtins.input" , return_value = "1" )
31
32
@patch ("sys.stdout" , new_callable = StringIO )
32
33
def test_default_theme_option_1 (self , mock_stdout , mock_input ):
@@ -77,23 +78,11 @@ def test_default_theme_invalid_input(self, mock_stdout, mock_input):
77
78
output = strip_ansi_codes (mock_stdout .getvalue ())
78
79
self .assertIn ("Generate:" , output )
79
80
80
- @patch ("builtins.input" , return_value = "1" )
81
- @patch ("sys.stdout" , new_callable = StringIO )
82
- def test_legacy_theme_option_1 (self , mock_stdout , mock_input ):
83
- """
84
- Test the interactive_menu with legacy theme and user selects option '1'.
85
- """
86
- choice = interactive_menu (self .config_legacy )
87
- self .assertEqual (choice , "1" )
88
- output = strip_ansi_codes (mock_stdout .getvalue ())
89
- self .assertIn ("Generate:" , output )
90
- self .assertIn ("1) Contribution stats (by author)" , output )
91
-
92
81
@patch ("builtins.input" , return_value = "3" )
93
82
@patch ("sys.stdout" , new_callable = StringIO )
94
83
def test_none_theme_option_3 (self , mock_stdout , mock_input ):
95
84
"""
96
- Test the interactive_menu with 'none' theme (alias for colorless) and user selects option '3'.
85
+ Test the interactive_menu with 'none' theme and user selects option '3'.
97
86
"""
98
87
choice = interactive_menu (self .config_none )
99
88
self .assertEqual (choice , "3" )
@@ -103,41 +92,43 @@ def test_none_theme_option_3(self, mock_stdout, mock_input):
103
92
self .assertNotIn ("\033 [36m" , output )
104
93
self .assertIn ("\033 [1m" , output )
105
94
106
- @patch ("builtins.input" , return_value = "22 " )
95
+ @patch ("builtins.input" , return_value = "1 " )
107
96
@patch ("sys.stdout" , new_callable = StringIO )
108
- def test_default_theme_option_22 (self , mock_stdout , mock_input ):
97
+ def test_none_theme_option_1 (self , mock_stdout , mock_input ):
109
98
"""
110
- Test the interactive_menu with default theme and user selects option '22 '.
99
+ Test the interactive_menu with 'none' theme and user selects option '1 '.
111
100
"""
112
- choice = interactive_menu (self .config_default )
113
- self .assertEqual (choice , "22" )
114
- output = strip_ansi_codes (mock_stdout .getvalue ())
115
- self .assertIn ("Suggest:" , output )
116
- self .assertIn ("22) Code reviewers (based on git history)" , output )
101
+ choice = interactive_menu (self .config_none )
102
+ self .assertEqual (choice , "1" )
103
+ output = mock_stdout .getvalue ()
104
+ self .assertNotIn ("\033 [31m" , output )
105
+ self .assertNotIn ("\033 [33m" , output )
106
+ self .assertNotIn ("\033 [36m" , output )
107
+ self .assertIn ("\033 [1m" , output )
117
108
118
109
@patch ("builtins.input" , return_value = "" )
119
110
@patch ("sys.stdout" , new_callable = StringIO )
120
- def test_default_theme_exit (self , mock_stdout , mock_input ):
111
+ def test_none_theme_exit (self , mock_stdout , mock_input ):
121
112
"""
122
- Test the interactive_menu with default theme and user presses Enter to exit.
113
+ Test the interactive_menu with none theme and user presses Enter to exit.
123
114
"""
124
- choice = interactive_menu (self .config_default )
115
+ choice = interactive_menu (self .config_none )
125
116
self .assertEqual (choice , "" )
126
117
output = strip_ansi_codes (mock_stdout .getvalue ())
127
118
self .assertIn ("press Enter to exit" , output )
128
119
129
120
@patch ("builtins.input" , return_value = "invalid" )
130
121
@patch ("sys.stdout" , new_callable = StringIO )
131
- def test_default_theme_invalid_input (self , mock_stdout , mock_input ):
122
+ def test_none_theme_invalid_input (self , mock_stdout , mock_input ):
132
123
"""
133
- Test the interactive_menu with default theme and user enters an invalid option.
124
+ Test the interactive_menu with none theme and user enters an invalid option.
134
125
"""
135
- choice = interactive_menu (self .config_default )
126
+ choice = interactive_menu (self .config_none )
136
127
self .assertEqual (choice , "invalid" )
137
- # Since interactive_menu doesn't print 'Invalid selection', we don't assert that here.
138
128
output = strip_ansi_codes (mock_stdout .getvalue ())
139
129
self .assertIn ("Generate:" , output )
140
130
131
+ # Test cases for legacy theme
141
132
@patch ("builtins.input" , return_value = "1" )
142
133
@patch ("sys.stdout" , new_callable = StringIO )
143
134
def test_legacy_theme_option_1 (self , mock_stdout , mock_input ):
@@ -183,6 +174,7 @@ def test_legacy_theme_invalid_input(self, mock_stdout, mock_input):
183
174
output = strip_ansi_codes (mock_stdout .getvalue ())
184
175
self .assertIn ("Generate:" , output )
185
176
177
+ # Test cases for handling multiple inputs and edge cases
186
178
@patch ("builtins.input" , side_effect = ["1" , "" ])
187
179
@patch ("sys.stdout" , new_callable = StringIO )
188
180
def test_multiple_inputs (self , mock_stdout , mock_input ):
@@ -207,6 +199,7 @@ def test_input_with_whitespace(self, mock_stdout, mock_input):
207
199
output = strip_ansi_codes (mock_stdout .getvalue ())
208
200
self .assertIn ("5) My daily status" , output )
209
201
202
+ # Test cases for handling exit commands
210
203
@patch ("builtins.input" , return_value = "QUIT" )
211
204
@patch ("sys.stdout" , new_callable = StringIO )
212
205
def test_input_quit (self , mock_stdout , mock_input ):
@@ -251,5 +244,6 @@ def test_keyboard_interrupt(self, mock_stdout, mock_input):
251
244
output = strip_ansi_codes (mock_stdout .getvalue ())
252
245
self .assertIn ("Generate:" , output )
253
246
247
+
254
248
if __name__ == "__main__" :
255
249
unittest .main ()
0 commit comments