Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,10 @@ def __update_table(self, params: dict[str, Par], fc_parameters: dict[str, float]
try:
for i, (param_name, param) in enumerate(params.items(), 1):
current_param_name = param_name
param_metadata = self.local_filesystem.doc_dict.get(param_name, None)
param_metadata = self.local_filesystem.doc_dict.get(param_name, {})
param_default = self.local_filesystem.param_default_dict.get(param_name, None)
doc_tooltip = (
param_metadata.get("doc_tooltip")
if param_metadata
else _("No documentation available in apm.pdef.xml for this parameter")
doc_tooltip = param_metadata.get(
"doc_tooltip", _("No documentation available in apm.pdef.xml for this parameter")
)

column: list[tk.Widget] = []
Expand Down Expand Up @@ -240,8 +238,8 @@ def __create_delete_button(self, param_name: str) -> ttk.Button:
return delete_button

def __create_parameter_name(self, param_name: str, param_metadata: dict[str, Any], doc_tooltip: str) -> ttk.Label:
is_calibration = param_metadata.get("Calibration", False) if param_metadata else False
is_readonly = param_metadata.get("ReadOnly", False) if param_metadata else False
is_calibration = param_metadata.get("Calibration", False)
is_readonly = param_metadata.get("ReadOnly", False)
parameter_label = ttk.Label(
self.view_port,
text=param_name + (" " * (16 - len(param_name))),
Expand Down Expand Up @@ -472,11 +470,9 @@ def update_label() -> None:
window.wait_window() # Wait for the window to be closed

def __create_unit_label(self, param_metadata: dict[str, Union[float, str]]) -> ttk.Label:
unit_label = ttk.Label(self.view_port, text=param_metadata.get("unit", "") if param_metadata else "")
unit_label = ttk.Label(self.view_port, text=param_metadata.get("unit", ""))
unit_tooltip = str(
param_metadata.get("unit_tooltip")
if param_metadata
else _("No documentation available in apm.pdef.xml for this parameter")
param_metadata.get("unit_tooltip", _("No documentation available in apm.pdef.xml for this parameter"))
)
if unit_tooltip:
show_tooltip(unit_label, unit_tooltip)
Expand Down
12 changes: 7 additions & 5 deletions tests/test_frontend_tkinter_template_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
from ardupilot_methodic_configurator.backend_filesystem_vehicle_components import VehicleComponents
from ardupilot_methodic_configurator.frontend_tkinter_template_overview import TemplateOverviewWindow, argument_parser, main

# pylint: disable=unused-argument,protected-access
# pylint: disable=useless-suppression
# pylint: disable=unused-argument,protected-access,invalid-name
# pylint: enable=useless-suppression
# ruff: noqa: ARG001


Expand Down Expand Up @@ -401,8 +403,8 @@ def test_tree_bindings(self, mock_vehicle_components, mock_toplevel) -> None:
window.tree = MagicMock()

# Create mocks for the private methods using the correct name mangling format
window._TemplateOverviewWindow__on_row_selection_change = MagicMock() # pylint: disable=invalid-name
window._TemplateOverviewWindow__on_row_double_click = MagicMock() # pylint: disable=invalid-name
window._TemplateOverviewWindow__on_row_selection_change = MagicMock()
window._TemplateOverviewWindow__on_row_double_click = MagicMock()

# Manually call the binding code
window.tree.bind("<ButtonRelease-1>", window._TemplateOverviewWindow__on_row_selection_change)
Expand Down Expand Up @@ -434,7 +436,7 @@ def test_column_heading_command(mock_vehicle_components, mock_toplevel) -> None:
window.tree["columns"] = ["col1", "col2"]

# Create a mock for __sort_by_column that we can track
window._TemplateOverviewWindow__sort_by_column = MagicMock() # pylint: disable=invalid-name
window._TemplateOverviewWindow__sort_by_column = MagicMock()

# Directly call heading for each column instead of using a loop
window.tree.heading(
Expand Down Expand Up @@ -797,7 +799,7 @@ def safe_after(ms, func) -> None:
window.root.after.side_effect = safe_after

# Create a mock update_selection that raises an exception
window._TemplateOverviewWindow__update_selection = MagicMock(side_effect=Exception("Test exception")) # pylint: disable=invalid-name
window._TemplateOverviewWindow__update_selection = MagicMock(side_effect=Exception("Test exception"))

# Call the method
window._TemplateOverviewWindow__on_row_selection_change(mock_event)
Expand Down
Loading