@@ -25,7 +25,9 @@ def setUp(self):
25
25
# Mock configurations for testing
26
26
self .config_default = {} # Default theme
27
27
self .config_legacy = {"menu_theme" : "legacy" } # Legacy theme
28
+ self .config_none = {"menu_theme" : "none" } # Alternate colorless theme alias
28
29
30
+ # Test cases for default theme
29
31
@patch ("builtins.input" , return_value = "1" )
30
32
@patch ("sys.stdout" , new_callable = StringIO )
31
33
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):
76
78
output = strip_ansi_codes (mock_stdout .getvalue ())
77
79
self .assertIn ("Generate:" , output )
78
80
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
79
132
@patch ("builtins.input" , return_value = "1" )
80
133
@patch ("sys.stdout" , new_callable = StringIO )
81
134
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):
121
174
output = strip_ansi_codes (mock_stdout .getvalue ())
122
175
self .assertIn ("Generate:" , output )
123
176
177
+ # Test cases for handling multiple inputs and edge cases
124
178
@patch ("builtins.input" , side_effect = ["1" , "" ])
125
179
@patch ("sys.stdout" , new_callable = StringIO )
126
180
def test_multiple_inputs (self , mock_stdout , mock_input ):
@@ -145,6 +199,7 @@ def test_input_with_whitespace(self, mock_stdout, mock_input):
145
199
output = strip_ansi_codes (mock_stdout .getvalue ())
146
200
self .assertIn ("5) My daily status" , output )
147
201
202
+ # Test cases for handling exit commands
148
203
@patch ("builtins.input" , return_value = "QUIT" )
149
204
@patch ("sys.stdout" , new_callable = StringIO )
150
205
def test_input_quit (self , mock_stdout , mock_input ):
0 commit comments