mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 17:03:56 +08:00
* comma car segments
* comma car segments for test_models
* oneliner
Co-authored-by: Shane Smiskol <shane@smiskol.com>
* better name
* not used here
* sort
* remove print
* better comment
---------
Co-authored-by: Shane Smiskol <shane@smiskol.com>
old-commit-hash: caa9153974
42 lines
912 B
Python
42 lines
912 B
Python
|
|
|
|
import unittest
|
|
|
|
import requests
|
|
from openpilot.tools.lib.comma_car_segments import get_comma_car_segments_database, get_url
|
|
from openpilot.tools.lib.logreader import LogReader, get_first_message
|
|
from openpilot.tools.lib.route import SegmentRange
|
|
|
|
|
|
class TestCommaCarSegments(unittest.TestCase):
|
|
def test_database(self):
|
|
database = get_comma_car_segments_database()
|
|
|
|
platforms = database.keys()
|
|
|
|
assert len(platforms) > 100
|
|
|
|
def test_download_segment(self):
|
|
database = get_comma_car_segments_database()
|
|
|
|
fp = "SUBARU FORESTER 2019"
|
|
|
|
segment = database[fp][0]
|
|
|
|
sr = SegmentRange(segment)
|
|
|
|
url = get_url(sr.route_name, sr._slice)
|
|
|
|
resp = requests.get(url)
|
|
self.assertEqual(resp.status_code, 200)
|
|
|
|
lr = LogReader(url)
|
|
|
|
CP = get_first_message(lr, "carParams").carParams
|
|
|
|
self.assertEqual(CP.carFingerprint, fp)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|