From b31a64d68cf7de81b960d7613661cdc367090ec5 Mon Sep 17 00:00:00 2001 From: "Dr.-Ing. Amilcar do Carmo Lucas" Date: Tue, 31 Dec 2024 16:19:20 +0100 Subject: [PATCH] IMPROVEMENT: re-order tests --- ...rameter_editor_documentation_frame_test.py | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/unittests/frontend_tkinter_parameter_editor_documentation_frame_test.py b/unittests/frontend_tkinter_parameter_editor_documentation_frame_test.py index c5d4c150..559981fb 100755 --- a/unittests/frontend_tkinter_parameter_editor_documentation_frame_test.py +++ b/unittests/frontend_tkinter_parameter_editor_documentation_frame_test.py @@ -31,6 +31,32 @@ def setUp(self) -> None: self.local_filesystem.get_seq_tooltip_text.side_effect = ["What text", "Why text", "Why now text"] self.doc_frame = DocumentationFrame(self.root, self.local_filesystem, self.current_file) + def test_create_documentation_frame(self) -> None: + """Test the creation of the documentation frame.""" + self.assertIsInstance(self.doc_frame.documentation_frame, ttk.LabelFrame) + self.assertEqual(self.doc_frame.documentation_frame.cget("text"), "test_file Documentation") + + expected_labels = ["Forum Blog:", "Wiki:", "External tool:", "Mandatory:"] + for label in expected_labels: + self.assertIn(label, self.doc_frame.documentation_labels) + + @patch("ardupilot_methodic_configurator.frontend_tkinter_parameter_editor_documentation_frame.webbrowser_open") + def test_auto_open_documentation_links(self, mock_webbrowser_open) -> None: + """Test the automatic opening of documentation links.""" + self.local_filesystem.get_documentation_text_and_url.side_effect = [ + ("Blog text", "http://blog.url"), + ("Wiki text", "http://wiki.url"), + ("External tool text", "http://external_tool.url"), + ("Mandatory text", None), + ] + self.doc_frame.auto_open_var.set(True) + + self.doc_frame.update_documentation_labels(self.current_file) + + mock_webbrowser_open.assert_any_call(url="http://wiki.url", new=0, autoraise=False) + mock_webbrowser_open.assert_any_call(url="http://external_tool.url", new=0, autoraise=False) + mock_webbrowser_open.assert_any_call(url="http://blog.url", new=0, autoraise=True) + @patch("ardupilot_methodic_configurator.frontend_tkinter_parameter_editor_documentation_frame.show_tooltip") def test_update_what_why_why_now_tooltip(self, _mock_show_tooltip) -> None: """Test the update_what_why_why_now_tooltip method.""" @@ -62,32 +88,6 @@ def test_update_documentation_labels(self, mock_show_tooltip, _mock_webbrowser_o # mock_show_tooltip.assert_any_call(self.doc_frame.documentation_labels["Mandatory:"], # "Documentation URL not available") - @patch("ardupilot_methodic_configurator.frontend_tkinter_parameter_editor_documentation_frame.webbrowser_open") - def test_auto_open_documentation_links(self, mock_webbrowser_open) -> None: - """Test the automatic opening of documentation links.""" - self.local_filesystem.get_documentation_text_and_url.side_effect = [ - ("Blog text", "http://blog.url"), - ("Wiki text", "http://wiki.url"), - ("External tool text", "http://external_tool.url"), - ("Mandatory text", None), - ] - self.doc_frame.auto_open_var.set(True) - - self.doc_frame.update_documentation_labels(self.current_file) - - mock_webbrowser_open.assert_any_call(url="http://wiki.url", new=0, autoraise=False) - mock_webbrowser_open.assert_any_call(url="http://external_tool.url", new=0, autoraise=False) - mock_webbrowser_open.assert_any_call(url="http://blog.url", new=0, autoraise=True) - - def test_create_documentation_frame(self) -> None: - """Test the creation of the documentation frame.""" - self.assertIsInstance(self.doc_frame.documentation_frame, ttk.LabelFrame) - self.assertEqual(self.doc_frame.documentation_frame.cget("text"), "test_file Documentation") - - expected_labels = ["Forum Blog:", "Wiki:", "External tool:", "Mandatory:"] - for label in expected_labels: - self.assertIn(label, self.doc_frame.documentation_labels) - if __name__ == "__main__": unittest.main()