openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

import pytest
from openpilot.system.hardware import TICI
from openpilot.system.hardware.tici.esim import LPA2, LPAProfileNotFoundError
1 week ago
# https://euicc-manual.osmocom.org/docs/rsp/known-test-profile
1 week ago
TEST_ACTIVATION_CODE = 'LPA:1$rsp.truphone.com$QRF-BETTERROAMING-PMRDGIR2EARDEIT5'
TEST_ICCID = '8944476500001944011'
1 week ago
1 week ago
TEST_NICKNAME = 'test_profile'
def cleanup():
lpa = LPA2()
try:
lpa.delete_profile(TEST_ICCID)
except LPAProfileNotFoundError:
pass
assert lpa.get_active_profile() is None
lpa.process_notifications()
assert len(lpa.list_notifications()) == 0
class TestEsim:
@classmethod
def setup_class(cls):
if not TICI:
pytest.skip()
1 week ago
return
cleanup()
1 week ago
def teardown_class(self):
cleanup()
def test_list_profiles(self):
lpa = LPA2()
profiles = lpa.list_profiles()
assert profiles is not None
1 week ago
def test_download_enable_disable_profile(self):
lpa = LPA2()
lpa.download_profile(self.TEST_ACTIVATION_CODE, self.TEST_NICKNAME)
1 week ago
assert self._profile_exists(lpa, self.TEST_ICCID, self.TEST_NICKNAME)
1 week ago
self._enable_profile(lpa)
self._disable_profile(lpa)
1 week ago
def _enable_profile(self, lpa: LPA2):
lpa.enable_profile(self.TEST_ICCID)
current = lpa.get_active_profile()
assert current is not None
assert current['iccid'] == self.TEST_ICCID
1 week ago
def _disable_profile(self, lpa: LPA2):
lpa.disable_profile(self.TEST_ICCID)
current = lpa.get_active_profile()
assert current is None
1 week ago
def _profile_exists(self, lpa: LPA2, iccid: str, nickname: str) -> bool:
profiles = lpa.list_profiles()
return any(p['iccid'] == iccid and p['nickname'] == nickname for p in profiles)