Skip to content

Commit

Permalink
IMPROVEMENT: re-order tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Dec 31, 2024
1 parent 4abf2e1 commit b31a64d
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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()

0 comments on commit b31a64d

Please sign in to comment.