Skip to content

Add explicit "import from FC" button, improve import of configured vehicles - #2047

Open
amilcarlucas wants to merge 5 commits into
masterfrom
more_autoimports
Open

amilcarlucas wants to merge 5 commits into
masterfrom
more_autoimports

fix(parameter-editor): respect imported parameter precedence

4506212
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
GitHub Actions / Test Results failed Sep 14, 2026 in 0s

1 fail, 7 skipped, 5 209 pass in 39m 37s

     4 files  ± 0       4 suites  ±0   39m 37s ⏱️ -59s
 5 217 tests +18   5 209 ✅ +17   7 💤 ±0  1 ❌ +1 
20 646 runs  +72  20 603 ✅ +68  39 💤 ±0  4 ❌ +4 

Results for commit 4506212. ± Comparison against earlier commit 73fe361.

Annotations

Check warning on line 0 in tests.test__main__.TestEditorBackupAndMainOrchestration

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 4 runs failed: test_main_forwards_initial_import_before_parameter_editor_starts (tests.test__main__.TestEditorBackupAndMainOrchestration)

artifacts/coverage-macos-latest-3.14-xml/results-junit.xml [took 0s]
artifacts/coverage-ubuntu-latest-3.10-xml/results-junit.xml [took 0s]
artifacts/coverage-ubuntu-latest-3.14-xml/results-junit.xml [took 0s]
artifacts/coverage-windows-latest-3.14-xml/results-junit.xml [took 0s]
Raw output
KeyError: 'initial_import'
self = <test__main__.TestEditorBackupAndMainOrchestration object at 0x112093ce0>

    def test_main_forwards_initial_import_before_parameter_editor_starts(self) -> None:
        """
        Initial-import changes are processed before the parameter editor starts.
    
        GIVEN: Startup creates a project through an initial-import workflow
        WHEN: The application completes component editing
        THEN: process_component_editor_results receives the import flag
        AND: It runs before parameter_editor_and_uploader
        """
        fc_mock = MagicMock()
        fc_mock.fc_parameters = {}
        events: list[str] = []
    
        def _init_fs(state: object) -> None:
            state.flight_controller = fc_mock  # type: ignore[union-attr]
            state.local_filesystem = MagicMock()  # type: ignore[union-attr]
            state.local_filesystem.file_parameters = {}
            state.local_filesystem.doc_dict = {}
            state.local_filesystem.vehicle_dir = "/fake"
            state.local_filesystem.get_fc_fw_version_from_vehicle_components_json.return_value = "4.7.0"
            state.param_default_values_dirty = False  # type: ignore[union-attr]
    
        def _select_vehicle_directory(state: object) -> None:
            state.vehicle_project_manager = MagicMock(initial_import_workflow=True)  # type: ignore[union-attr]
    
        with (
            patch("ardupilot_methodic_configurator.__main__.create_argument_parser") as mock_parser,
            patch("ardupilot_methodic_configurator.__main__.register_plugins"),
            patch("ardupilot_methodic_configurator.__main__.FreeDesktop.create_desktop_icon_if_needed"),
            patch("ardupilot_methodic_configurator.__main__.setup_logging"),
            patch("ardupilot_methodic_configurator.__main__.ProgramSettings.migrate_settings_to_latest_version"),
            patch("ardupilot_methodic_configurator.__main__.check_updates", return_value=False),
            patch("ardupilot_methodic_configurator.__main__.PopupWindow.should_display", return_value=False),
            patch(
                "ardupilot_methodic_configurator.__main__.ProgramSettings.get_setting",
                side_effect=lambda key: False if key != "gui_complexity" else "normal",
            ),
            patch("ardupilot_methodic_configurator.__main__.initialize_flight_controller"),
            patch("ardupilot_methodic_configurator.__main__.initialize_filesystem", side_effect=_init_fs),
            patch(
                "ardupilot_methodic_configurator.__main__.vehicle_directory_selection", side_effect=_select_vehicle_directory
            ),
            patch("ardupilot_methodic_configurator.__main__.plugin_factory.validate_configuration_steps"),
            patch(
                "ardupilot_methodic_configurator.__main__.component_editor",
                side_effect=lambda _state: events.append("component_editor"),
            ),
            patch("ardupilot_methodic_configurator.__main__.process_component_editor_results") as mock_process,
            patch("ardupilot_methodic_configurator.__main__.backup_fc_parameters"),
            patch("ardupilot_methodic_configurator.__main__.upgrade_parameters_for_firmware_version"),
            patch(
                "ardupilot_methodic_configurator.__main__.parameter_editor_and_uploader",
                side_effect=lambda _state: events.append("parameter_editor"),
            ),
            patch("ardupilot_methodic_configurator.__main__.sys_exit"),
        ):
            mock_process.side_effect = lambda *_args, **_kwargs: events.append("process_components")
            mock_parser.return_value.parse_args.return_value = argparse.Namespace(
                loglevel="INFO",
                skip_check_for_updates=False,
                vehicle_dir=None,
                vehicle_type=None,
                device=None,
                reboot_time=5,
                baudrate=115200,
                n=0,
                skip_component_editor=False,
                allow_editing_template_files=False,
                export_fc_params_missing_or_different=False,
            )
    
            main()
    
        mock_process.assert_called_once()
>       assert mock_process.call_args.kwargs["initial_import"] is True
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       KeyError: 'initial_import'

tests/test__main__.py:1997: KeyError