Files
StarPilot/openpilot/starpilot/aol/tests/test_dm_lazy.py
T
firestar5683 80fbb4f6db Feature registration
Register vehicle controls, planner modes, UI actions and Galaxy services after their providers exist. Wire the shared runtime entrypoints and cover their combined behavior.

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Kacper Rączy <gfw.kra@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
Co-authored-by: stef <19478336+stefpi@users.noreply.github.com>
Co-authored-by: whoisdomi <dcantu83@gmail.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: haraschax <6804392+haraschax@users.noreply.github.com>
Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

39 lines
1.6 KiB
Python

from contextlib import ExitStack
from unittest import mock
import pytest
from openpilot.starpilot.aol import dm as owner
from openpilot.starpilot.aol.tests.stock_lateral_test_helpers import callers
@pytest.mark.parametrize('family', ['gm', 'toyota'])
@pytest.mark.parametrize('restriction', ['healthy', 'red', 'lockout', 'always_lockout', 'invalid', 'native_denied'])
def test_actual_dm_proof_is_lazy_only_without_an_exception(family, restriction):
with ExitStack() as cleanup:
sd, _, drive, _, _ = callers(cleanup, family, True)
original = sd.update_events
def events(state):
value = sd.sm['driverMonitoringState'].as_builder()
value.alertLevel = 'three' if restriction in ('red', 'native_denied') else 'none'
value.lockout = restriction == 'lockout'
value.alwaysOnLockout = restriction == 'always_lockout'
sd.sm.data['driverMonitoringState'] = value.as_reader()
if restriction == 'invalid':
sd.sm.valid['driverMonitoringState'] = False
return original(state)
cleanup.enter_context(mock.patch.object(sd, 'update_events', side_effect=events))
with mock.patch.object(owner, 'armed_lateral_current', wraps=owner.armed_lateral_current) as proof:
axis, _, command = drive(2, native_request_long=False, allowed=restriction != 'native_denied')
if restriction in ('healthy', 'invalid'):
proof.assert_not_called()
else:
assert proof.call_count > 0
if restriction in ('invalid', 'native_denied'):
assert not axis.lateralActive and not command.latActive
else:
assert axis.lateralActive and command.latActive
assert not axis.longitudinalActive and not command.longActive