@@ -62,6 +62,10 @@ def setUp(self) -> None:
6262 return_value = self .mock_combobox ,
6363 ),
6464 patch ("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.show_tooltip" ),
65+ patch (
66+ "ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.get_connection_history" ,
67+ return_value = [],
68+ ),
6569 ):
6670 self .widget = ConnectionSelectionWidgets (
6771 self .mock_parent ,
@@ -226,7 +230,10 @@ def test_add_connection_canceled(self, mock_logging_debug, mock_askstring) -> No
226230 self .mock_flight_controller .add_connection .reset_mock ()
227231
228232 # Patch the reconnect method to prevent it from being called
229- with patch .object (self .widget , "reconnect" ):
233+ with (
234+ patch .object (self .widget , "reconnect" ),
235+ patch ("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.store_connection" ),
236+ ):
230237 # Call the method
231238 result = self .widget .add_connection ()
232239
@@ -239,7 +246,10 @@ def test_add_connection_canceled(self, mock_logging_debug, mock_askstring) -> No
239246
240247 # Test with empty string input
241248 mock_askstring .return_value = ""
242- with patch .object (self .widget , "reconnect" ):
249+ with (
250+ patch .object (self .widget , "reconnect" ),
251+ patch ("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.store_connection" ),
252+ ):
243253 result = self .widget .add_connection ()
244254 assert result == ""
245255 self .mock_flight_controller .add_connection .assert_not_called ()
@@ -262,13 +272,17 @@ def test_add_connection_success(self, mock_logging_debug, mock_askstring) -> Non
262272 ("Add another" , "Add another connection" ),
263273 ]
264274
265- # Reset mocks
275+ # Reset mocks to clear any previous test state
276+ self .mock_flight_controller .add_connection .reset_mock ()
266277 self .mock_flight_controller .get_connection_tuples .reset_mock ()
267278 self .mock_flight_controller .get_connection_tuples .return_value = updated_tuples
268279 self .mock_combobox .reset_mock ()
269280
270- # Patch the reconnect method
271- with patch .object (self .widget , "reconnect" ) as mock_reconnect :
281+ # Patch the reconnect method and ProgramSettings
282+ with (
283+ patch .object (self .widget , "reconnect" ) as mock_reconnect ,
284+ patch ("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.store_connection" ),
285+ ):
272286 # Call the method
273287 result = self .widget .add_connection ()
274288
0 commit comments