@@ -27,6 +27,7 @@ def setUp(self):
2727 self .config_legacy = {"menu_theme" : "legacy" } # Legacy theme
2828 self .config_none = {"menu_theme" : "none" } # Alternate colorless theme alias
2929
30+ # Test cases for default theme
3031 @patch ("builtins.input" , return_value = "1" )
3132 @patch ("sys.stdout" , new_callable = StringIO )
3233 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):
7778 output = strip_ansi_codes (mock_stdout .getvalue ())
7879 self .assertIn ("Generate:" , output )
7980
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-
9281 @patch ("builtins.input" , return_value = "3" )
9382 @patch ("sys.stdout" , new_callable = StringIO )
9483 def test_none_theme_option_3 (self , mock_stdout , mock_input ):
9584 """
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'.
9786 """
9887 choice = interactive_menu (self .config_none )
9988 self .assertEqual (choice , "3" )
@@ -103,41 +92,43 @@ def test_none_theme_option_3(self, mock_stdout, mock_input):
10392 self .assertNotIn ("\033 [36m" , output )
10493 self .assertIn ("\033 [1m" , output )
10594
106- @patch ("builtins.input" , return_value = "22 " )
95+ @patch ("builtins.input" , return_value = "1 " )
10796 @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 ):
10998 """
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 '.
111100 """
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 )
117108
118109 @patch ("builtins.input" , return_value = "" )
119110 @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 ):
121112 """
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.
123114 """
124- choice = interactive_menu (self .config_default )
115+ choice = interactive_menu (self .config_none )
125116 self .assertEqual (choice , "" )
126117 output = strip_ansi_codes (mock_stdout .getvalue ())
127118 self .assertIn ("press Enter to exit" , output )
128119
129120 @patch ("builtins.input" , return_value = "invalid" )
130121 @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 ):
132123 """
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.
134125 """
135- choice = interactive_menu (self .config_default )
126+ choice = interactive_menu (self .config_none )
136127 self .assertEqual (choice , "invalid" )
137- # Since interactive_menu doesn't print 'Invalid selection', we don't assert that here.
138128 output = strip_ansi_codes (mock_stdout .getvalue ())
139129 self .assertIn ("Generate:" , output )
140130
131+ # Test cases for legacy theme
141132 @patch ("builtins.input" , return_value = "1" )
142133 @patch ("sys.stdout" , new_callable = StringIO )
143134 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):
183174 output = strip_ansi_codes (mock_stdout .getvalue ())
184175 self .assertIn ("Generate:" , output )
185176
177+ # Test cases for handling multiple inputs and edge cases
186178 @patch ("builtins.input" , side_effect = ["1" , "" ])
187179 @patch ("sys.stdout" , new_callable = StringIO )
188180 def test_multiple_inputs (self , mock_stdout , mock_input ):
@@ -207,6 +199,7 @@ def test_input_with_whitespace(self, mock_stdout, mock_input):
207199 output = strip_ansi_codes (mock_stdout .getvalue ())
208200 self .assertIn ("5) My daily status" , output )
209201
202+ # Test cases for handling exit commands
210203 @patch ("builtins.input" , return_value = "QUIT" )
211204 @patch ("sys.stdout" , new_callable = StringIO )
212205 def test_input_quit (self , mock_stdout , mock_input ):
@@ -251,5 +244,6 @@ def test_keyboard_interrupt(self, mock_stdout, mock_input):
251244 output = strip_ansi_codes (mock_stdout .getvalue ())
252245 self .assertIn ("Generate:" , output )
253246
247+
254248if __name__ == "__main__" :
255249 unittest .main ()
0 commit comments