Repair alert and Galaxy test fixtures

This commit is contained in:
firestar5683
2026-11-23 23:37:59 -06:00
parent 22f010c1ac
commit 48fb24ee48
14 changed files with 30 additions and 13 deletions
@@ -8,6 +8,7 @@ from openpilot.common.params import Params
from opendbc.car import structs
from openpilot.selfdrive.selfdrived.alertmanager import AlertManager
from openpilot.selfdrive.selfdrived.events import Events, ET, Alert, Priority
from openpilot.starpilot.aol.runtime import AxisDecision
from openpilot.starpilot.controllers.mode_actions import SwitchbackCooldown
from openpilot.selfdrive.selfdrived.selfdrived import SelfdriveD
from openpilot.starpilot.longitudinal.force_stop_alert import HoldAlertState
@@ -42,6 +43,7 @@ class Sources:
def fixture():
drive = SelfdriveD.__new__(SelfdriveD)
drive.aol_axis_decision = AxisDecision()
drive.CP = structs.CarParams(openpilotLongitudinalControl=True)
drive.enabled, drive.personality, drive.is_metric = True, log.LongitudinalPersonality.standard, False
vars(drive)['state_machine'] = NS(current_alert_types=[ET.WARNING], soft_disable_timer=0)
@@ -7,6 +7,7 @@ import unittest
from opendbc.car.structs import car
from openpilot.cereal import log
from openpilot.starpilot.aol.runtime import AxisDecision
from openpilot.starpilot.controllers.mode_actions import SwitchbackCooldown
from openpilot.selfdrive.selfdrived.alertmanager import AlertManager
from openpilot.selfdrive.selfdrived.events import Alert, ET, EVENTS, Events, Priority
@@ -34,6 +35,7 @@ class TestLaneChangeAlert(unittest.TestCase):
model = SimpleNamespace(frameId=frame_id, timestampEof=10_000_000_000,
meta=SimpleNamespace(laneChangeDirection="left"))
drive = SelfdriveD.__new__(SelfdriveD)
drive.aol_axis_decision = AxisDecision()
drive.events = Events()
drive.events.add(EventName.preLaneChangeLeft)
self.enterContext(patch.object(drive, "state_machine", SimpleNamespace(current_alert_types=[ET.WARNING], soft_disable_timer=0), create=True))
@@ -120,7 +120,7 @@ class TestActualFreshCardStartup(TestCase):
patch.object(manager, 'save_bootlog'), \
patch.object(manager.HARDWARE, 'get_serial', return_value='fixture'), \
patch.object(manager.HARDWARE, 'get_device_type', return_value='pc'), \
patch.object(manager, 'register', return_value='fixture'), \
patch.object(manager, 'register_at_startup', return_value='fixture'), \
patch.object(manager.cloudlog, 'bind_global'):
manager.manager_init()
target = Path(params.get_param_path('AlwaysOnLateral'))
@@ -244,7 +244,9 @@ def test_actual_selfdrived_alert_path_works_disengaged_and_resets_offroad(monkey
from openpilot.selfdrive.selfdrived.state import StateMachine
from openpilot.starpilot.controllers.mode_actions import SwitchbackCooldown
from openpilot.starpilot.longitudinal.force_stop_alert import HoldAlertState
from openpilot.starpilot.aol.runtime import AxisDecision
daemon = SelfdriveD.__new__(SelfdriveD)
daemon.aol_axis_decision = AxisDecision()
daemon.CP, daemon.AM = vehicle(), AlertManager()
daemon.sm = messaging.SubMaster(['deviceState', 'radarTracks'])
daemon.events, daemon.enabled, daemon.personality, daemon.is_metric = Events(), False, 1, True
@@ -3,6 +3,7 @@ from types import SimpleNamespace
from opendbc.car import structs
from openpilot.starpilot.aol.intent import AolSettings
from openpilot.starpilot.aol.runtime import AxisDecision
from openpilot.starpilot.car.subaru.aol import SubaruStockCardIntent
@@ -254,7 +255,7 @@ def test_legacy_2025_line_visibility_and_passive_dashcam_chimes():
drive.switchback_setting_ns = now
drive.switchback_cooldown_ns = 0
drive.switchback_cooldown = SwitchbackCooldown()
drive.aol_axis_decision = None
drive.aol_axis_decision = AxisDecision()
drive.aol_fault_reason = 'none'
drive.radar_recovery_enabled = False
drive.legacy_2025_green_wheel_active = True
@@ -159,7 +159,9 @@ def test_bound_custom_receipt_reaches_selfdrived_alert_manager_without_core_even
internal = SimpleNamespace(di_cruise_state='ENABLED' if current else 'OFF',
cruiseEnabled=not_armed, enableLongControl=not_armed)
alerts = receive(cp, internal, state, previous=previous)
from openpilot.starpilot.aol.runtime import AxisDecision
drive = SelfdriveD.__new__(SelfdriveD)
drive.aol_axis_decision = AxisDecision()
drive.CP, drive.enabled, drive.is_metric = cp, False, False
drive.personality = log.LongitudinalPersonality.standard
vars(drive)['state_machine'] = SimpleNamespace(current_alert_types=[category], soft_disable_timer=0)
@@ -114,6 +114,8 @@ DESCRIPTIONS = {
'GMAutoHold': 'Holds the brakes at a stop with cruise main on. Press the accelerator or the supported regen paddle to release.',
'VoltOnePedalMode': 'Slows and holds a Volt when you lift off the accelerator in Low or single-pedal mode, with cruise main on and cruise disengaged.',
'LongPitch': 'Compensates acceleration and braking for road grade.',
'CoastDownhills': 'Lets the car coast above set speed on descents within the configured allowance.',
'DownhillSpeedSurplus': 'Sets how far above set speed downhill coasting can go.',
'GMLongitudinalTune': 'Selects the supported vehicle speed-control response tune.',
'TruckTuning': 'Softens small acceleration requests, reduces grade correction and smooths light braking on supported GM trucks.',
'EVTuning': 'Selects EV acceleration curves for inherited acceleration presets.',
@@ -440,5 +440,7 @@
"wheel:VeryLongCancelButtonControl",
"wheel:VeryLongDistanceButtonControl",
"wheel:VeryLongModeButtonControl",
"wheel:VeryLongStarButtonControl"
"wheel:VeryLongStarButtonControl",
"CoastDownhills",
"DownhillSpeedSurplus"
]
@@ -142,7 +142,8 @@ class SharedDeviceStateTest(unittest.TestCase):
# this display adapter consumes only deviceState and pandaStates.
self.messages.values.update(carState=SimpleNamespace(), selfdriveState=SimpleNamespace(), carParams=SimpleNamespace(),
peripheralState=SimpleNamespace(pandaType=1, voltage=12640),
lateralDelay=SimpleNamespace(), lateralTorqueParameters=SimpleNamespace(), vehicleParameters=SimpleNamespace())
lateralDelay=SimpleNamespace(), lateralTorqueParameters=SimpleNamespace(), vehicleParameters=SimpleNamespace(),
chestnutGpuState=SimpleNamespace())
self.shared = EvidenceSource(self.messages, mono=self.clock.mono, boot=self.clock.boot)
self.addCleanup(self.shared.close)
@@ -151,7 +152,8 @@ class SharedDeviceStateTest(unittest.TestCase):
self.messages.publish(self.clock, **state)
self.messages.values.update(carState=SimpleNamespace(), selfdriveState=SimpleNamespace(), carParams=SimpleNamespace(),
peripheralState=SimpleNamespace(pandaType=1, voltage=12640),
lateralDelay=SimpleNamespace(), lateralTorqueParameters=SimpleNamespace(), vehicleParameters=SimpleNamespace())
lateralDelay=SimpleNamespace(), lateralTorqueParameters=SimpleNamespace(), vehicleParameters=SimpleNamespace(),
chestnutGpuState=SimpleNamespace())
self.messages.alive = dict(self.messages.seen)
self.shared.poll()
@@ -28,7 +28,7 @@ class Messages:
'pandaStates': [NS(pandaType='uno', ignitionLine=ignition, ignitionCan=False, controlsAllowed=False, safetyModel='noOutput')],
'carState': NS(canValid=True, canTimeout=False, standstill=True, gearShifter='park'),
'selfdriveState': NS(enabled=False, active=False), 'carParams': NS(notCar=True), 'peripheralState': NS(pandaType=1, voltage=12640)}
self.data.update({service: NS() for service in ('lateralDelay', 'lateralTorqueParameters', 'vehicleParameters')})
self.data.update({service: NS() for service in ('lateralDelay', 'lateralTorqueParameters', 'vehicleParameters', 'chestnutGpuState')})
self.seen = self.alive = self.valid = dict.fromkeys(EvidenceSource.SERVICES, True)
self.updated = dict(self.seen)
self.logMonoTime = {name: boot if name == 'pandaStates' else mono for name in EvidenceSource.SERVICES}
@@ -920,7 +920,7 @@ class SettingsGatewayTest(unittest.TestCase):
cp.openpilotLongitudinalControl = True
cp.pcmCruise = False
self.context.value = replace(self.context.value, cp=cp)
from openpilot.starpilot.lateral.lane_change_preferences import read_saved as read_lane_change
from openpilot.starpilot.lateral.lane_change_preferences import DOCUMENT_VERSION, read_saved as read_lane_change
page = self.page("lane_change")
close = next(i for i, row in enumerate(page["rows"]) if row["label"] == "Close lane-change gap")
@@ -940,7 +940,7 @@ class SettingsGatewayTest(unittest.TestCase):
self.assertTrue(self.gateway.confirm(intent["intent"], self.session, self.generation))
self.assertEqual(read_lane_change(self.params).policy.close_gap_seconds, 0.8)
self.assertEqual(self.page("lane_change")["rows"][gap]["value"], "0.8")
self.assertEqual(self.params.get("LaneChangePreferences")["version"], 6)
self.assertEqual(self.params.get("LaneChangePreferences")["version"], DOCUMENT_VERSION)
saved = self.page("lane_change")
revoke = self.gateway.preview(saved["view"], close, -1, self.session, self.generation)
@@ -11,8 +11,9 @@ from openpilot.selfdrive.ui.ui_state import ChestnutState, UIState
@pytest.mark.parametrize('raw, expected', [(True, True), (False, False), (b'1', True), (b'0', False),
('1', True), ('0', False), (None, None), (b'invalid', None)])
def test_native_chestnut_status_accepts_typed_params(raw, expected):
def test_native_chestnut_status_accepts_typed_params(raw, expected, tmp_path):
params = Mock()
params.get_param_path.side_effect = lambda key: str(tmp_path / key)
params.get.return_value = raw
params.get_bool.return_value = False
state = Mock(spec=UIState, params=params, started=True, chestnut_compiled=True, usb_connected=False)
@@ -84,8 +85,9 @@ def test_offroad_status_uses_selected_download(detected, installed, checking, ex
assert state.chestnut_state == expected
def test_offroad_selection_rechecks_without_a_ui_restart():
def test_offroad_selection_rechecks_without_a_ui_restart(tmp_path):
params = Mock()
params.get_param_path.side_effect = lambda key: str(tmp_path / key)
params.get.return_value = None
params.get_bool.return_value = False
artifacts = Mock()
@@ -93,7 +93,7 @@ def ui_fake():
sm.put("deviceState", NS(started=True, networkType=NS(raw=1), networkStrength=NS(raw=2), lastAthenaPingTime=NOW,
maxTempC=65.6, thermalStatus=log.DeviceState.ThermalStatus.ok))
sm.put("pandaStates", [NS(pandaType=log.PandaState.PandaType.tres, ignitionLine=True, ignitionCan=False)])
sm.put("carState", NS(vEgoCluster=15.0, vEgo=16.0, vCruiseCluster=80.0))
sm.put("carState", NS(vEgoCluster=15.0, vEgo=16.0, vCruiseCluster=80.0, standstill=False))
sm.put("carControl", NS(latActive=True, longActive=False, actuators=NS(torque=0.3)))
sm.put("selfdriveState", NS(experimentalMode=False, alertSize=NS(raw=0), alertStatus=NS(raw=0),
alertText1="", alertText2=""))
@@ -276,7 +276,7 @@ class TestRuntimeSnapshot(unittest.TestCase):
ui.is_metric = metric
home = adapter.build(ShellMode.HOME, now_ns=NOW).home
self.assertEqual(home.temperature_c, temperature)
self.assertEqual(home.metric, metric)
self.assertEqual(home.temperature_metric, metric)
text.reset_mock()
edge.reset_mock()
view._sidebar(home)
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "407e57d1c05893a7ee3bd5248ff1d6d42dd5fa3b22d387a4b7acd58fa25fd58d", "schema_version": 1}
{"protected_inventory_sha256": "374e6f70c29ebe927b415e32865fae9ff5ff4140e92b343e9b206f9d6fb8035d", "schema_version": 1}