CarInfo: Add test for missing platform info (#24607)
* Add test for missing car info
* Make optional
old-commit-hash: b73d7cf3a5
This commit is contained in:
parent
8456b0e79c
commit
0f85c8a19c
|
@ -1,6 +1,6 @@
|
|||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from selfdrive.car import dbc_dict
|
||||
from selfdrive.car.docs_definitions import CarInfo, Harness
|
||||
|
@ -31,8 +31,9 @@ class ChryslerCarInfo(CarInfo):
|
|||
harness: Enum = Harness.fca
|
||||
|
||||
|
||||
CAR_INFO: Dict[str, Union[ChryslerCarInfo, List[ChryslerCarInfo]]] = {
|
||||
CAR_INFO: Dict[str, Optional[Union[ChryslerCarInfo, List[ChryslerCarInfo]]]] = {
|
||||
CAR.PACIFICA_2017_HYBRID: ChryslerCarInfo("Chrysler Pacifica Hybrid 2017-18"),
|
||||
CAR.PACIFICA_2018_HYBRID: None, # same platforms
|
||||
CAR.PACIFICA_2019_HYBRID: ChryslerCarInfo("Chrysler Pacifica Hybrid 2019-21"),
|
||||
CAR.PACIFICA_2018: ChryslerCarInfo("Chrysler Pacifica 2017-18"),
|
||||
CAR.PACIFICA_2020: ChryslerCarInfo("Chrysler Pacifica 2020"),
|
||||
|
|
|
@ -34,7 +34,7 @@ def get_all_car_info() -> List[CarInfo]:
|
|||
fingerprint = {0: {}, 1: {HKG_RADAR_START_ADDR: 8}, 2: {}, 3: {}}
|
||||
CP = interfaces[model][0].get_params(model, fingerprint=fingerprint, disable_radar=True)
|
||||
|
||||
if CP.dashcamOnly:
|
||||
if CP.dashcamOnly or car_info is None:
|
||||
continue
|
||||
|
||||
# A platform can include multiple car models
|
||||
|
|
|
@ -35,6 +35,8 @@ class CAR:
|
|||
|
||||
|
||||
CAR_INFO: Dict[str, Union[CarInfo, List[CarInfo]]] = {
|
||||
CAR.ESCAPE_MK4: CarInfo("Ford Escape", "NA"),
|
||||
CAR.FOCUS_MK4: CarInfo("Ford Focus", "NA"),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from dataclasses import dataclass
|
||||
from enum import Enum, IntFlag
|
||||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from cereal import car
|
||||
from common.conversions import Conversions as CV
|
||||
|
@ -106,7 +106,7 @@ class HondaCarInfo(CarInfo):
|
|||
min_steer_speed: float = 12. * CV.MPH_TO_MS
|
||||
|
||||
|
||||
CAR_INFO: Dict[str, Union[HondaCarInfo, List[HondaCarInfo]]] = {
|
||||
CAR_INFO: Dict[str, Optional[Union[HondaCarInfo, List[HondaCarInfo]]]] = {
|
||||
CAR.ACCORD: [
|
||||
HondaCarInfo("Honda Accord 2018-21", "All", video_link="https://www.youtube.com/watch?v=mrUwlj3Mi58", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch),
|
||||
HondaCarInfo("Honda Inspire 2018", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch),
|
||||
|
@ -117,15 +117,17 @@ CAR_INFO: Dict[str, Union[HondaCarInfo, List[HondaCarInfo]]] = {
|
|||
HondaCarInfo("Honda Civic 2019-20", "All", video_link="https://www.youtube.com/watch?v=4Iz1Mz5LGF8", footnotes=[Footnote.CIVIC_DIESEL], min_steer_speed=2. * CV.MPH_TO_MS, harness=Harness.bosch),
|
||||
HondaCarInfo("Honda Civic Hatchback 2017-21", harness=Harness.bosch),
|
||||
],
|
||||
CAR.CIVIC_BOSCH_DIESEL: None, # same platform
|
||||
CAR.ACURA_ILX: HondaCarInfo("Acura ILX 2016-19", "AcuraWatch Plus", min_steer_speed=25. * CV.MPH_TO_MS, harness=Harness.nidec),
|
||||
CAR.CRV: HondaCarInfo("Honda CR-V 2015-16", "Touring", harness=Harness.nidec),
|
||||
CAR.CRV_5G: HondaCarInfo("Honda CR-V 2017-21", harness=Harness.bosch),
|
||||
# CAR.CRV_EU: HondaCarInfo("Honda CR-V EU", "Touring"), # Euro version of CRV Touring
|
||||
CAR.CRV_EU: None, # HondaCarInfo("Honda CR-V EU", "Touring"), # Euro version of CRV Touring
|
||||
CAR.CRV_HYBRID: HondaCarInfo("Honda CR-V Hybrid 2017-19", harness=Harness.bosch),
|
||||
CAR.FIT: HondaCarInfo("Honda Fit 2018-19", harness=Harness.nidec),
|
||||
CAR.FREED: HondaCarInfo("Honda Freed 2020", harness=Harness.nidec),
|
||||
CAR.HRV: HondaCarInfo("Honda HR-V 2019-20", harness=Harness.nidec),
|
||||
CAR.ODYSSEY: HondaCarInfo("Honda Odyssey 2018-20", min_steer_speed=0., harness=Harness.nidec),
|
||||
CAR.ODYSSEY_CHN: None, # Chinese version of Odyssey
|
||||
CAR.ACURA_RDX: HondaCarInfo("Acura RDX 2016-18", "AcuraWatch Plus", harness=Harness.nidec),
|
||||
CAR.ACURA_RDX_3G: HondaCarInfo("Acura RDX 2019-21", "All", min_steer_speed=3. * CV.MPH_TO_MS, harness=Harness.bosch),
|
||||
CAR.PILOT: HondaCarInfo("Honda Pilot 2016-21", harness=Harness.nidec),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from dataclasses import dataclass
|
||||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from cereal import car
|
||||
from common.conversions import Conversions as CV
|
||||
|
@ -81,10 +81,11 @@ class HyundaiCarInfo(CarInfo):
|
|||
good_torque: bool = True
|
||||
|
||||
|
||||
CAR_INFO: Dict[str, Union[HyundaiCarInfo, List[HyundaiCarInfo]]] = {
|
||||
CAR_INFO: Dict[str, Optional[Union[HyundaiCarInfo, List[HyundaiCarInfo]]]] = {
|
||||
CAR.ELANTRA: HyundaiCarInfo("Hyundai Elantra 2017-19", min_enable_speed=19 * CV.MPH_TO_MS, harness=Harness.hyundai_b),
|
||||
CAR.ELANTRA_2021: HyundaiCarInfo("Hyundai Elantra 2021-22", video_link="https://youtu.be/_EdYQtV52-c", harness=Harness.hyundai_k),
|
||||
CAR.ELANTRA_HEV_2021: HyundaiCarInfo("Hyundai Elantra Hybrid 2021-22", video_link="https://youtu.be/_EdYQtV52-c", harness=Harness.hyundai_k),
|
||||
CAR.ELANTRA_GT_I30: None, # dashcamOnly and same platform as CAR.ELANTRA
|
||||
CAR.HYUNDAI_GENESIS: HyundaiCarInfo("Hyundai Genesis 2015-16", min_enable_speed=19 * CV.MPH_TO_MS, harness=Harness.hyundai_j),
|
||||
CAR.IONIQ: HyundaiCarInfo("Hyundai Ioniq Hybrid 2017-19", harness=Harness.hyundai_c),
|
||||
CAR.IONIQ_HEV_2022: HyundaiCarInfo("Hyundai Ioniq Hybrid 2020-22", "SCC + LFA", harness=Harness.hyundai_h),
|
||||
|
@ -129,6 +130,7 @@ CAR_INFO: Dict[str, Union[HyundaiCarInfo, List[HyundaiCarInfo]]] = {
|
|||
HyundaiCarInfo("Kia Optima 2017", min_steer_speed=32. * CV.MPH_TO_MS, harness=Harness.hyundai_b),
|
||||
HyundaiCarInfo("Kia Optima 2019", harness=Harness.hyundai_g),
|
||||
],
|
||||
CAR.KIA_OPTIMA_H: HyundaiCarInfo("Kia Optima 2017, 2019"), # TODO: info may be incorrect
|
||||
CAR.KIA_SELTOS: HyundaiCarInfo("Kia Seltos 2021", harness=Harness.hyundai_a),
|
||||
CAR.KIA_SORENTO: [
|
||||
HyundaiCarInfo("Kia Sorento 2018", video_link="https://www.youtube.com/watch?v=Fkh3s6WHJz8", harness=Harness.hyundai_c),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from selfdrive.car.docs_definitions import CarInfo
|
||||
|
||||
|
@ -7,4 +7,6 @@ class CAR:
|
|||
MOCK = 'mock'
|
||||
|
||||
|
||||
CAR_INFO: Dict[str, Union[CarInfo, List[CarInfo]]] = {}
|
||||
CAR_INFO: Dict[str, Optional[Union[CarInfo, List[CarInfo]]]] = {
|
||||
CAR.MOCK: None,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from dataclasses import dataclass
|
||||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
from enum import Enum
|
||||
|
||||
from selfdrive.car import dbc_dict
|
||||
|
@ -32,9 +32,10 @@ class NissanCarInfo(CarInfo):
|
|||
harness: Enum = Harness.nissan_a
|
||||
|
||||
|
||||
CAR_INFO: Dict[str, Union[NissanCarInfo, List[NissanCarInfo]]] = {
|
||||
CAR_INFO: Dict[str, Optional[Union[NissanCarInfo, List[NissanCarInfo]]]] = {
|
||||
CAR.XTRAIL: NissanCarInfo("Nissan X-Trail 2017"),
|
||||
CAR.LEAF: NissanCarInfo("Nissan Leaf 2018-22"),
|
||||
CAR.LEAF_IC: None, # same platforms
|
||||
CAR.ROGUE: NissanCarInfo("Nissan Rogue 2018-20"),
|
||||
CAR.ALTIMA: NissanCarInfo("Nissan Altima 2019-20", harness=Harness.nissan_b),
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import unittest
|
||||
|
||||
from selfdrive.car.car_helpers import interfaces, get_interface_attr
|
||||
from selfdrive.car.docs import CARS_MD_OUT, CARS_MD_TEMPLATE, generate_cars_md, get_all_car_info
|
||||
|
||||
|
||||
|
@ -16,6 +17,12 @@ class TestCarDocs(unittest.TestCase):
|
|||
self.assertEqual(generated_cars_md, current_cars_md,
|
||||
"Run selfdrive/car/docs.py to generate new supported cars documentation")
|
||||
|
||||
def test_missing_car_info(self):
|
||||
all_car_info_platforms = [p for i in get_interface_attr("CAR_INFO").values() for p in i]
|
||||
for platform in sorted(interfaces.keys()):
|
||||
if platform not in all_car_info_platforms:
|
||||
self.fail("Platform: {} doesn't exist in CarInfo".format(platform))
|
||||
|
||||
def test_naming_conventions(self):
|
||||
# Asserts market-standard car naming conventions by make
|
||||
for car in self.all_cars:
|
||||
|
|
Loading…
Reference in New Issue