@@ -25,7 +25,9 @@ def setUp(self):
2525 # Mock configurations for testing
2626 self .config_default = {} # Default theme
2727 self .config_legacy = {"menu_theme" : "legacy" } # Legacy theme
28+ self .config_none = {"menu_theme" : "none" } # Alternate colorless theme alias
2829
30+ # Test cases for default theme
2931 @patch ("builtins.input" , return_value = "1" )
3032 @patch ("sys.stdout" , new_callable = StringIO )
3133 def test_default_theme_option_1 (self , mock_stdout , mock_input ):
@@ -76,6 +78,57 @@ def test_default_theme_invalid_input(self, mock_stdout, mock_input):
7678 output = strip_ansi_codes (mock_stdout .getvalue ())
7779 self .assertIn ("Generate:" , output )
7880
81+ @patch ("builtins.input" , return_value = "3" )
82+ @patch ("sys.stdout" , new_callable = StringIO )
83+ def test_none_theme_option_3 (self , mock_stdout , mock_input ):
84+ """
85+ Test the interactive_menu with 'none' theme and user selects option '3'.
86+ """
87+ choice = interactive_menu (self .config_none )
88+ self .assertEqual (choice , "3" )
89+ output = mock_stdout .getvalue ()
90+ self .assertNotIn ("\033 [31m" , output )
91+ self .assertNotIn ("\033 [33m" , output )
92+ self .assertNotIn ("\033 [36m" , output )
93+ self .assertIn ("\033 [1m" , output )
94+
95+ @patch ("builtins.input" , return_value = "1" )
96+ @patch ("sys.stdout" , new_callable = StringIO )
97+ def test_none_theme_option_1 (self , mock_stdout , mock_input ):
98+ """
99+ Test the interactive_menu with 'none' theme and user selects option '1'.
100+ """
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 )
108+
109+ @patch ("builtins.input" , return_value = "" )
110+ @patch ("sys.stdout" , new_callable = StringIO )
111+ def test_none_theme_exit (self , mock_stdout , mock_input ):
112+ """
113+ Test the interactive_menu with none theme and user presses Enter to exit.
114+ """
115+ choice = interactive_menu (self .config_none )
116+ self .assertEqual (choice , "" )
117+ output = strip_ansi_codes (mock_stdout .getvalue ())
118+ self .assertIn ("press Enter to exit" , output )
119+
120+ @patch ("builtins.input" , return_value = "invalid" )
121+ @patch ("sys.stdout" , new_callable = StringIO )
122+ def test_none_theme_invalid_input (self , mock_stdout , mock_input ):
123+ """
124+ Test the interactive_menu with none theme and user enters an invalid option.
125+ """
126+ choice = interactive_menu (self .config_none )
127+ self .assertEqual (choice , "invalid" )
128+ output = strip_ansi_codes (mock_stdout .getvalue ())
129+ self .assertIn ("Generate:" , output )
130+
131+ # Test cases for legacy theme
79132 @patch ("builtins.input" , return_value = "1" )
80133 @patch ("sys.stdout" , new_callable = StringIO )
81134 def test_legacy_theme_option_1 (self , mock_stdout , mock_input ):
@@ -121,6 +174,7 @@ def test_legacy_theme_invalid_input(self, mock_stdout, mock_input):
121174 output = strip_ansi_codes (mock_stdout .getvalue ())
122175 self .assertIn ("Generate:" , output )
123176
177+ # Test cases for handling multiple inputs and edge cases
124178 @patch ("builtins.input" , side_effect = ["1" , "" ])
125179 @patch ("sys.stdout" , new_callable = StringIO )
126180 def test_multiple_inputs (self , mock_stdout , mock_input ):
@@ -145,6 +199,7 @@ def test_input_with_whitespace(self, mock_stdout, mock_input):
145199 output = strip_ansi_codes (mock_stdout .getvalue ())
146200 self .assertIn ("5) My daily status" , output )
147201
202+ # Test cases for handling exit commands
148203 @patch ("builtins.input" , return_value = "QUIT" )
149204 @patch ("sys.stdout" , new_callable = StringIO )
150205 def test_input_quit (self , mock_stdout , mock_input ):
0 commit comments