test(rc-calibration): hardware-free test suite for RCCalibrationDataModel (99% cov) - #1819
test(rc-calibration): hardware-free test suite for RCCalibrationDataModel (99% cov)#1819iacker wants to merge 4 commits into
Conversation
Signed-off-by: Dr.-Ing. Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
Adds 25 hardware-free unit tests for data_model_rc_calibration.py using a mocked FlightController (MagicMock), following the BDD Given-When-Then style already used in test_data_model_accelerometer_calibration.py. Coverage of data_model_rc_calibration.py: 99% (all statements, 25/26 branches). Covered behaviours: - connection state (connected / disconnected) - start/cancel calibration and stale-state clearing - finish_calibration: RCn_MIN/MAX/TRIM writes, midpoint trim, symmetric max fallback, 0-based to 1-based channel mapping, state cleanup - RC_CHANNELS telemetry: axis mapping, invalid-PWM sentinel handling, chancount bound, swallowed recv_match exceptions, HEARTBEAT flight_mode - min/max tracking active only while calibrating No hardware required: all MAVLink I/O is mocked. Signed-off-by: Billard <82095453+iacker@users.noreply.github.com>
|
Are you using VS code? Can you run the local task: pylint ? |
|
Hi @amilcarlucas, thanks a lot for taking the time to review this. Really appreciate it! 🙏 I ran pylint locally as you suggested. Good news: the test file itself ( I've got a small fix ready that extracts a shared Also, this RC calibration plugin is a really cool piece of work, the 3D quad view idea in #1816 looks great. Glad to help however is most useful. 🚁 |
Removes the duplicated window-centering block (R0801) shared between CalibrationPopupBase and CompassCalibrationInstructionsPopup. Both now call a single module-level center_over_parent() helper. Behavior unchanged; fixes the pylint 3.14 duplicate-code failure.
Coverage Report for CI Build 29290259188Warning No base build found for commit Coverage: 93.125%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats💛 - Coveralls |
| _ModelT = TypeVar("_ModelT") | ||
|
|
||
|
|
||
| def center_over_parent(window: tk.Toplevel, parent: tk.Misc, width: int, height: int) -> None: |
There was a problem hiding this comment.
I think this function belongs in the ardupilot_methodic_configurator\frontend_tkinter_base_window.py file.
That file already contains two related functions:
def center_window(window: tk.Toplevel | tk.Tk, parent: tk.Toplevel | tk.Tk) -> None:
def center_window_on_screen(window: tk.Toplevel | tk.Tk) -> None:
Changes-requested addressed@amilcarlucas all $ pylint --rcfile=.pylintrc tests/test_data_model_rc_calibration.py
Your code has been rated at 10.00/10
$ pylint --rcfile=.pylintrc ardupilot_methodic_configurator/data_model_rc_calibration.py ardupilot_methodic_configurator/frontend_tkinter_rc_calibration.py
Your code has been rated at 10.00/10Test suite also runs clean with 99% coverage on the data model: $ python -m pytest tests/test_data_model_rc_calibration.py -q --cov=ardupilot_methodic_configurator.data_model_rc_calibration --cov-report=term-missing
25 passed in 0.16s
Cover Missing
99% 140->139Ready for re-review. |
de962ef to
2ae479a
Compare
|
Thanks for this. I merged it. |
Adds 25 hardware-free unit tests for
data_model_rc_calibration.py(mocked FlightController, BDD style matching the accelerometer calibration tests). Coverage: 99%.Targets your WIP branch
RC_Calibration(#1816) so it merges straight into the plugin.Covered: connection state, start/cancel, finish_calibration (RCn_MIN/MAX/TRIM writes, midpoint trim, symmetric max fallback, 0-based→1-based mapping, cleanup), RC_CHANNELS telemetry (axis mapping, invalid-PWM 65535 sentinel, chancount bound, swallowed recv_match exceptions, HEARTBEAT flight_mode), min/max tracking gated on calibrating state.
No hardware required — pure software data model. All MAVLink I/O is mocked.