diff --git a/tests/test_frontend_tkinter_connection_selection.py b/tests/test_frontend_tkinter_connection_selection.py index 2aa7fd84..be349b4e 100755 --- a/tests/test_frontend_tkinter_connection_selection.py +++ b/tests/test_frontend_tkinter_connection_selection.py @@ -62,6 +62,10 @@ def setUp(self) -> None: return_value=self.mock_combobox, ), patch("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.show_tooltip"), + patch( + "ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.get_connection_history", + return_value=[], + ), ): self.widget = ConnectionSelectionWidgets( self.mock_parent, @@ -226,7 +230,10 @@ def test_add_connection_canceled(self, mock_logging_debug, mock_askstring) -> No self.mock_flight_controller.add_connection.reset_mock() # Patch the reconnect method to prevent it from being called - with patch.object(self.widget, "reconnect"): + with ( + patch.object(self.widget, "reconnect"), + patch("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.store_connection"), + ): # Call the method result = self.widget.add_connection() @@ -239,7 +246,10 @@ def test_add_connection_canceled(self, mock_logging_debug, mock_askstring) -> No # Test with empty string input mock_askstring.return_value = "" - with patch.object(self.widget, "reconnect"): + with ( + patch.object(self.widget, "reconnect"), + patch("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.store_connection"), + ): result = self.widget.add_connection() assert result == "" 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 ("Add another", "Add another connection"), ] - # Reset mocks + # Reset mocks to clear any previous test state + self.mock_flight_controller.add_connection.reset_mock() self.mock_flight_controller.get_connection_tuples.reset_mock() self.mock_flight_controller.get_connection_tuples.return_value = updated_tuples self.mock_combobox.reset_mock() - # Patch the reconnect method - with patch.object(self.widget, "reconnect") as mock_reconnect: + # Patch the reconnect method and ProgramSettings + with ( + patch.object(self.widget, "reconnect") as mock_reconnect, + patch("ardupilot_methodic_configurator.frontend_tkinter_connection_selection.ProgramSettings.store_connection"), + ): # Call the method result = self.widget.add_connection()