fw_versions: type annotate test_brand_ecu_matches (#31272)

* test this

* we
old-commit-hash: 341f8420dbd309c8465e1872839baacd1c1f3438
This commit is contained in:
Shane Smiskol
2024-02-01 17:11:10 -06:00
committed by GitHub
parent d7aa7440e5
commit e2059a9293
2 changed files with 11 additions and 3 deletions
+2 -2
View File
@@ -201,12 +201,12 @@ def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[EcuAddrBusType]:
return ecu_responses
def get_brand_ecu_matches(ecu_rx_addrs):
def get_brand_ecu_matches(ecu_rx_addrs: Set[EcuAddrBusType]) -> dict[str, set[AddrType]]:
"""Returns dictionary of brands and matches with ECUs in their FW versions"""
brand_addrs = {brand: config.get_all_ecus(VERSIONS[brand], include_ecu_type=False) for
brand, config in FW_QUERY_CONFIGS.items()}
brand_matches = {brand: set() for brand, _, _ in REQUESTS}
brand_matches: dict[str, set[AddrType]] = {brand: set() for brand, _, _ in REQUESTS}
brand_rx_offsets = {(brand, r.rx_offset) for brand, _, r in REQUESTS}
for addr, sub_addr, _ in ecu_rx_addrs:
+9 -1
View File
@@ -11,7 +11,7 @@ from cereal import car
from openpilot.selfdrive.car.car_helpers import interfaces
from openpilot.selfdrive.car.fingerprints import FW_VERSIONS
from openpilot.selfdrive.car.fw_versions import FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \
match_fw_to_car, get_fw_versions, get_present_ecus
match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_present_ecus
from openpilot.selfdrive.car.vin import get_vin
CarFw = car.CarParams.CarFw
@@ -178,6 +178,14 @@ class TestFwFingerprint(unittest.TestCase):
self.assertFalse(request_obj.auxiliary and request_obj.bus == 1 and request_obj.obd_multiplexing,
f"{brand.title()}: OBD multiplexed request is marked auxiliary: {request_obj}")
def test_brand_ecu_matches(self):
empty_response = {brand: set() for brand in FW_QUERY_CONFIGS}
self.assertEqual(get_brand_ecu_matches(set()), empty_response)
# we ignore bus
expected_response = empty_response | {'toyota': {(0x750, 0xf)}}
self.assertEqual(get_brand_ecu_matches({(0x758, 0xf, 99)}), expected_response)
class TestFwFingerprintTiming(unittest.TestCase):
N: int = 5