Files
StarPilot/openpilot/starpilot/ui/tests/test_output_max_feature.py
T
firestar5683 a82935f326 User interfaces and Android Auto
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services.

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: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: Shane Smiskol <shane@smiskol.com>
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: pharmacomaniac <blittle65@gmail.com>

Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

59 lines
2.6 KiB
Python

"""Removed acceleration setting and refusal of stale configurable requests."""
from pathlib import Path
import tempfile
import unittest
from opendbc.car.honda.interface import CarInterface
from opendbc.car.honda.values import CAR
from openpilot.common.params import Params
from openpilot.starpilot.galaxy.settings import AuthorityContext, SettingsGateway
from openpilot.starpilot.longitudinal.output_max import KEY
from openpilot.starpilot.ui.feature_settings_owner import FeatureSettingsOwner
from openpilot.starpilot.ui.feature_settings_state import FeatureSettingsRequest
class Context:
def __init__(self, cp):
self.value = AuthorityContext(False, cp, b'current-cp')
def sample(self):
return self.value
class OutputMaximumFeatureTests(unittest.TestCase):
def setUp(self):
temporary = tempfile.TemporaryDirectory()
self.addCleanup(temporary.cleanup)
self.params = Params(temporary.name)
self.cp = CarInterface.get_non_essential_params(CAR.HONDA_CIVIC)
self.context = Context(self.cp)
self.gateway = SettingsGateway(self.params, self.context, clock=lambda: 10.)
self.owner = FeatureSettingsOwner(self.params, lambda group: True,
vehicle_fingerprint=lambda: getattr(self.context.value.cp, 'carFingerprint', None),
vehicle_params=lambda: self.context.value.cp)
def test_setting_absent_onroad_and_parked_with_saved_legacy_value(self):
path = Path(self.params.get_param_path(KEY))
for raw in (b'0.5', b'4.0', b'broken'):
path.write_bytes(raw)
for parked in (False, True):
for cp in (self.cp, None):
with self.subTest(raw=raw, parked=parked, cp=cp):
self.context.value = AuthorityContext(parked, cp, b'current-cp')
page = self.gateway.page('profiles', 'session', b'generation')
self.assertFalse(any(row['label'] == 'Maximum acceleration' for row in page['rows']))
rows = self.owner.snapshot('profiles', parked=parked, system_long=False, lateral_context=False, metric=False).rows
self.assertFalse(any(row.key == KEY for row in rows))
self.assertEqual(path.read_bytes(), raw)
def test_stale_numeric_repair_and_default_requests_cannot_write(self):
path = Path(self.params.get_param_path(KEY))
for raw in (b'0.5', b'broken'):
path.write_bytes(raw)
for value in ('0.1', '4.0', 'nan'):
for confirmed in (False, True):
request = FeatureSettingsRequest(KEY, raw, value, confirmation=confirmed)
self.assertFalse(self.owner.apply(request))
self.assertEqual(path.read_bytes(), raw)