Merge current tests with Toyota smartDSU priority

This commit is contained in:
firestar5683
2026-10-22 21:55:14 -05:00
6 changed files with 11 additions and 9 deletions
@@ -120,12 +120,13 @@ def test_native_unqualified_aol_profile_has_no_transmit_catalog(param):
assert rig.feed(feature=1, request=3) == 0
# Even an ordinary physical cruise engagement cannot give an unsupported
# AE32 profile a steering, longitudinal, wheel-touch or cruise-cancel TX slot.
for name, bus, values in (
messages: tuple[tuple[str, int, dict[str, float]], ...] = (
('ACM_lkaHbaCmd', 0, {'ACM_lkaStrToqReq': 0, 'ACM_lkaActToi': False}),
('ACM_longitudinalRequest', 0, {'ACM_AccelerationRequest': 0.0}),
('SCCM_WheelTouch', 2, {'SCCM_WheelTouch_HandsOn': 0}),
('VDM_AdasSts', 2, {'VDM_AdasInterfaceStatus': 0}),
):
)
for name, bus, values in messages:
address, data, frame_bus = rig.car.packer.make_can_msg(name, bus, values)
assert not rig.native.safety_tx_hook(libsafety_py.make_CANPacket(address, frame_bus, data))
View File
@@ -74,7 +74,7 @@ def server(tmp_path, monkeypatch):
with _LocalHTTPServer(('127.0.0.1', 0), Handler) as http:
services: set[int] = set()
http.loopback = lambda request: request.getpeername()[1] in services
monkeypatch.setattr(http, 'loopback', lambda request: request.getpeername()[1] in services)
http.services = services
thread = threading.Thread(target=http.serve_forever, kwargs={'poll_interval': .01}, daemon=True)
thread.start()
@@ -723,6 +723,8 @@ class SharedBluetoothOwner(BluetoothOwner):
if operation in ('scan', 'stop_scan'):
return super().request(operation, session=session)
if operation == 'pair':
if address is None:
raise ValueError('Invalid Bluetooth address')
address = normalized_address(address)
if address == lease.receiver:
raise BluetoothRejected('Use Android Auto to pair its receiver', code='projection_active')
@@ -82,8 +82,7 @@ class CompanionTests(unittest.TestCase):
host._lock = threading.RLock()
host.config = {'receiver_address': ADAPTER, 'companion_address': 'saved-car', 'companion_name': 'My car'}
host._shared_bluetooth_owner = self.owner
host._phone = lambda: self.phone
with patch('openpilot.starpilot.system.android_auto.identity.save_config') as save:
with patch.object(host, '_phone', return_value=self.phone), patch('openpilot.starpilot.system.android_auto.identity.save_config') as save:
host.companion_bluetooth_action('connect', CAR, SESSION)
host.companion_bluetooth_action('disconnect', CAR, SESSION)
save.assert_not_called()
@@ -307,7 +306,7 @@ class CompanionTests(unittest.TestCase):
self.assertFalse(self.lease.released)
def test_power_off_goes_through_the_owner_and_power_on_is_a_no_op(self):
self.owner.request = Mock(return_value={'powered': False}) # ty: ignore[invalid-assignment] # test double
self.owner.request = Mock(return_value={'powered': False}) # test double
self.assertEqual(self.owner.companion_power(False, SESSION), {'powered': False})
self.owner.request.assert_called_once_with('power', enabled=False, session=SESSION)
self.owner.request.reset_mock()
@@ -339,13 +338,13 @@ class CompanionTests(unittest.TestCase):
return daemon.handle(Mock(wraps=supervisor), request, Mock(wraps=SimpleNamespace(valid=lambda source: valid)), parked=lambda: parked)
def test_daemon_power_command_requires_proof_park_and_a_boolean(self):
self.owner.request = Mock(return_value={'powered': False}) # ty: ignore[invalid-assignment] # test double
self.owner.request = Mock(return_value={'powered': False}) # test double
self.assertEqual(self.power_call(), {'handled': True, 'bluetooth': {'powered': False}})
self.assertEqual(self.power_call(parked=False), {'handled': True, 'error_code': 'park_required'})
with self.assertRaises(RuntimeError):
self.power_call(valid=False)
with self.assertRaises(ValueError):
self.power_call(enabled='off') # ty: ignore[invalid-argument-type] # wrong type on purpose
self.power_call(enabled='off') # wrong type on purpose
self.lease.session = SESSION
self.assertEqual(self.power_call(), {'handled': True, 'error_code': 'busy', 'message': 'Finish Android Auto pairing first'})
self.owner.phone_lease = None
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "afb5deec264d70c79d1312cd8dda4142d4a9b223f2ae3ed4afb997f5e093ac07", "schema_version": 1}
{"protected_inventory_sha256": "9328db5991b9b00ad2744212ff945b578e270783a2a0c96bc5b054308129338f", "schema_version": 1}