@@ -93,8 +93,8 @@ def mock_program_provider() -> MagicMock:
93
93
94
94
95
95
@pytest .fixture
96
- def firmware_filtering_templates () -> dict [str , MagicMock ]:
97
- """Fixture providing mock templates for firmware filtering tests."""
96
+ def vehicle_filtering_templates () -> dict [str , MagicMock ]:
97
+ """Fixture providing mock templates for vehicle filtering tests."""
98
98
return {
99
99
"Copter/QuadX" : MagicMock (attributes = lambda : ["name" ], name = "QuadCopter" ),
100
100
"Plane/FixedWing" : MagicMock (attributes = lambda : ["name" ], name = "Airplane" ),
@@ -107,9 +107,9 @@ def firmware_filtering_templates() -> dict[str, MagicMock]:
107
107
108
108
109
109
@pytest .fixture
110
- def firmware_window (mock_vehicle_provider , mock_program_provider , firmware_filtering_templates ) -> TemplateOverviewWindow :
111
- """Fixture providing a configured window for firmware filtering tests."""
112
- mock_vehicle_provider .get_vehicle_components_overviews .return_value = firmware_filtering_templates
110
+ def vehicle_window (mock_vehicle_provider , mock_program_provider , vehicle_filtering_templates ) -> TemplateOverviewWindow :
111
+ """Fixture providing a configured window for vehicle filtering tests."""
112
+ mock_vehicle_provider .get_vehicle_components_overviews .return_value = vehicle_filtering_templates
113
113
114
114
with (
115
115
patch ("tkinter.Toplevel" ),
@@ -123,7 +123,7 @@ def firmware_window(mock_vehicle_provider, mock_program_provider, firmware_filte
123
123
window = TemplateOverviewWindow (
124
124
vehicle_components_provider = mock_vehicle_provider ,
125
125
program_settings_provider = mock_program_provider ,
126
- connected_fc_vehicle_type = "Copter " , # Default firmware type for filtering tests
126
+ connected_fc_vehicle_type = "ArduCopter " , # Default vehicle type for filtering tests
127
127
)
128
128
window .root = MagicMock ()
129
129
window .tree = MagicMock ()
@@ -1051,86 +1051,84 @@ def test_main_function_handles_no_recently_used_directories(self) -> None:
1051
1051
mock_log_info .assert_not_called ()
1052
1052
1053
1053
1054
- class TestFirmwareTypeFiltering :
1055
- """Test firmware type filtering functionality."""
1054
+ class TestVehicleTypeFiltering :
1055
+ """Test vehicle type filtering functionality."""
1056
1056
1057
- def test_filtering_shows_only_matching_firmware_templates (self , firmware_window ) -> None :
1057
+ def test_filtering_shows_only_matching_vehicle_templates (self , vehicle_window ) -> None :
1058
1058
"""
1059
- Test that firmware filtering shows only templates matching the connected flight controller.
1059
+ Test that vehicle filtering shows only templates matching the connected flight controller.
1060
1060
1061
- GIVEN: Multiple templates exist for different firmware types
1062
- WHEN: User has a specific firmware type connected (e.g., "Copter ")
1063
- THEN: Only templates matching that firmware type should be displayed
1061
+ GIVEN: Multiple templates exist for different vehicle types
1062
+ WHEN: User has a specific vehicle type connected (e.g., "ArduCopter ")
1063
+ THEN: Only templates matching that vehicle type should be displayed
1064
1064
"""
1065
1065
# Act: Populate treeview with Copter filtering
1066
- firmware_window ._populate_treeview ("Copter " )
1066
+ vehicle_window ._populate_treeview ("ArduCopter " )
1067
1067
1068
- # Assert: Only Copter templates are added
1069
- # Should include: Copter/QuadX, Copter/HexaX, ArduCopter/QuadX, and Custom/Copter/Experimental
1070
- assert firmware_window .tree .insert .call_count == 4
1068
+ # Assert: Only ArduCopter templates are added
1069
+ # Should not include: Copter/QuadX, Copter/HexaX, Custom/Copter/Experimental
1070
+ assert vehicle_window .tree .insert .call_count == 1
1071
1071
1072
1072
# Verify the calls contain only Copter templates
1073
- call_args_list = firmware_window .tree .insert .call_args_list
1073
+ call_args_list = vehicle_window .tree .insert .call_args_list
1074
1074
inserted_keys = [call [1 ]["text" ] for call in call_args_list ]
1075
- assert "Copter/QuadX" in inserted_keys
1076
- assert "Copter/HexaX" in inserted_keys
1075
+ assert "Copter/QuadX" not in inserted_keys
1076
+ assert "Copter/HexaX" not in inserted_keys
1077
1077
assert "ArduCopter/QuadX" in inserted_keys
1078
- assert "Custom/Copter/Experimental" in inserted_keys
1078
+ assert "Custom/Copter/Experimental" not in inserted_keys
1079
1079
assert "Plane/FixedWing" not in inserted_keys
1080
1080
assert "Rover/SkidSteer" not in inserted_keys
1081
1081
1082
- def test_no_filtering_shows_all_templates (self , firmware_window ) -> None :
1082
+ def test_no_filtering_shows_all_templates (self , vehicle_window ) -> None :
1083
1083
"""
1084
- Test that passing empty/None firmware type shows all available templates.
1084
+ Test that passing empty/None vehicle type shows all available templates.
1085
1085
1086
- GIVEN: Multiple templates exist for different firmware types
1087
- WHEN: No specific firmware type is provided for filtering
1086
+ GIVEN: Multiple templates exist for different vehicle types
1087
+ WHEN: No specific vehicle type is provided for filtering
1088
1088
THEN: All available templates should be displayed
1089
1089
"""
1090
1090
# Act: Populate treeview without filtering
1091
- firmware_window ._populate_treeview ("" )
1091
+ vehicle_window ._populate_treeview ("" )
1092
1092
1093
1093
# Assert: All templates are added
1094
- assert firmware_window .tree .insert .call_count == 7 # All seven templates
1094
+ assert vehicle_window .tree .insert .call_count == 7 # All seven templates
1095
1095
1096
1096
# Verify all template types are included
1097
- call_args_list = firmware_window .tree .insert .call_args_list
1097
+ call_args_list = vehicle_window .tree .insert .call_args_list
1098
1098
inserted_keys = [call [1 ]["text" ] for call in call_args_list ]
1099
1099
assert "Copter/QuadX" in inserted_keys
1100
1100
assert "Plane/FixedWing" in inserted_keys
1101
1101
assert "Rover/SkidSteer" in inserted_keys
1102
1102
assert "ArduCopter/QuadX" in inserted_keys
1103
1103
1104
- def test_partial_firmware_matching_works_correctly (self , firmware_window ) -> None :
1104
+ def test_partial_vehicle_matching_works_correctly (self , vehicle_window ) -> None :
1105
1105
"""
1106
- Test that firmware filtering works with partial string matching.
1106
+ Test that vehicle filtering works with partial string matching.
1107
1107
1108
- GIVEN: Templates with firmware types as part of their keys
1109
- WHEN: A specific firmware substring is used for filtering
1108
+ GIVEN: Templates with vehicle types as part of their keys
1109
+ WHEN: A specific vehicle substring is used for filtering
1110
1110
THEN: All templates containing that substring should be included
1111
1111
"""
1112
- # Act: Filter by "Copter " substring
1113
- firmware_window ._populate_treeview ("Copter " )
1112
+ # Act: Filter by "ArduCopter " substring
1113
+ vehicle_window ._populate_treeview ("ArduCopter " )
1114
1114
1115
- # Assert: Both ArduCopter and Custom/Copter templates are included
1116
- assert firmware_window .tree .insert .call_count == 4
1115
+ # Assert: Only ArduCopter templates are included
1116
+ assert vehicle_window .tree .insert .call_count == 1
1117
1117
1118
- call_args_list = firmware_window .tree .insert .call_args_list
1118
+ call_args_list = vehicle_window .tree .insert .call_args_list
1119
1119
inserted_keys = [call [1 ]["text" ] for call in call_args_list ]
1120
1120
assert "ArduCopter/QuadX" in inserted_keys
1121
- assert "Custom/Copter/Experimental" in inserted_keys
1122
- assert "Copter/QuadX" in inserted_keys
1121
+ assert "Custom/Copter/Experimental" not in inserted_keys
1122
+ assert "Copter/QuadX" not in inserted_keys
1123
1123
assert "ArduPlane/FixedWing" not in inserted_keys
1124
1124
1125
- def test_constructor_passes_firmware_type_to_configure_treeview (
1126
- self , mock_vehicle_provider , mock_program_provider
1127
- ) -> None :
1125
+ def test_constructor_passes_vehicle_type_to_configure_treeview (self , mock_vehicle_provider , mock_program_provider ) -> None :
1128
1126
"""
1129
- Test that the constructor properly passes firmware type to the configuration methods.
1127
+ Test that the constructor properly passes vehicle type to the configuration methods.
1130
1128
1131
- GIVEN: A TemplateOverviewWindow is created with a specific firmware type
1129
+ GIVEN: A TemplateOverviewWindow is created with a specific vehicle type
1132
1130
WHEN: The constructor initializes the UI components
1133
- THEN: The firmware type should be passed down to the treeview configuration
1131
+ THEN: The vehicle type should be passed down to the treeview configuration
1134
1132
"""
1135
1133
with (
1136
1134
patch ("tkinter.Toplevel" ),
@@ -1141,12 +1139,12 @@ def test_constructor_passes_firmware_type_to_configure_treeview(
1141
1139
patch .object (TemplateOverviewWindow , "_configure_treeview" ) as mock_configure_treeview ,
1142
1140
patch .object (TemplateOverviewWindow , "_bind_events" ),
1143
1141
):
1144
- # Act: Create window with specific firmware type
1142
+ # Act: Create window with specific vehicle type
1145
1143
TemplateOverviewWindow (
1146
1144
vehicle_components_provider = mock_vehicle_provider ,
1147
1145
program_settings_provider = mock_program_provider ,
1148
1146
connected_fc_vehicle_type = "Plane" ,
1149
1147
)
1150
1148
1151
- # Assert: Firmware type is passed to configure_treeview
1149
+ # Assert: vehicle type is passed to configure_treeview
1152
1150
mock_configure_treeview .assert_called_once_with ("Plane" )
0 commit comments