700756c16f
Initial commit. Delivers what the brief calls 'Sprint 0 - Foundations' (see docs/AR_Autopilot_brief.md section 12): - Complete repository structure (arautopilot package + firmware, display, installer, tools placeholders + docs). - Core data model (Pydantic v2): modes, alarms, actuator config, PID config + gain scheduling, vessel config, knob state machine, project config with YAML/JSON serialisation. - Seed library: 2 actuator profiles (hydraulic & electric DC reversible) and 2 default tunings (yacht motor planeo 30 m and 40 m). Conservative literature values, NOT the integrator's production tuning IP. - Firmware skeleton: only src/hal/pinout.h with the 21 I/O contract for the AR-NMEA-IO v1.0 board. No drivers, no main loop. - Studio stubs (real PySide6 app starts in Sprint 4). - pytest suite (80 tests, all green): modes, alarms, actuator, PID (incl. gain interpolation and the +/-50% adaptive bound from brief section 6), vessel, knob state, project config, library loader, end-to-end roundtrip. - examples/sprint0_demo.py - the acceptance demo from the brief. Acceptance criteria met: - pytest green (80/80) - demo creates, saves (YAML + JSON), reloads, and verifies a full ProjectConfig using the seed library - repository ready for tag `sprint-0-approved` See CHANGELOG.md for the detailed scope. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""Tests for ``arautopilot.core.modes``."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from arautopilot.core.modes import AutopilotMode, is_available_in_phase
|
|
|
|
|
|
def test_all_modes_have_string_values() -> None:
|
|
"""Every enum member must use a kebab/snake-style string value (for serialisation)."""
|
|
for m in AutopilotMode:
|
|
assert isinstance(m.value, str)
|
|
assert m.value == m.value.lower()
|
|
assert " " not in m.value
|
|
|
|
|
|
def test_phase_1_modes_are_exactly_the_five_brief_modes() -> None:
|
|
expected = {
|
|
AutopilotMode.STANDBY,
|
|
AutopilotMode.HEADING_HOLD,
|
|
AutopilotMode.TRUE_COURSE,
|
|
AutopilotMode.TRACK_KEEPING,
|
|
AutopilotMode.DODGE,
|
|
}
|
|
got = {m for m in AutopilotMode if is_available_in_phase(m, 1)}
|
|
assert got == expected
|
|
|
|
|
|
def test_phase_2_modes_include_phase_1_plus_wind_modes() -> None:
|
|
phase_2 = {m for m in AutopilotMode if is_available_in_phase(m, 2)}
|
|
expected = {
|
|
AutopilotMode.STANDBY,
|
|
AutopilotMode.HEADING_HOLD,
|
|
AutopilotMode.TRUE_COURSE,
|
|
AutopilotMode.TRACK_KEEPING,
|
|
AutopilotMode.DODGE,
|
|
AutopilotMode.APPARENT_WIND,
|
|
AutopilotMode.TRUE_WIND,
|
|
AutopilotMode.AUTO_TACK,
|
|
}
|
|
assert phase_2 == expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"mode",
|
|
[AutopilotMode.APPARENT_WIND, AutopilotMode.TRUE_WIND, AutopilotMode.AUTO_TACK],
|
|
)
|
|
def test_wind_modes_disabled_in_phase_1(mode: AutopilotMode) -> None:
|
|
assert not is_available_in_phase(mode, 1)
|
|
|
|
|
|
@pytest.mark.parametrize("phase", [0, 3, 99, -1])
|
|
def test_unknown_phases_disable_everything(phase: int) -> None:
|
|
for m in AutopilotMode:
|
|
assert not is_available_in_phase(m, phase)
|