diff --git a/system/hardware/tici/tests/test_esim.py b/system/hardware/tici/tests/test_esim.py index 7ae05217a9..bf1921cd89 100644 --- a/system/hardware/tici/tests/test_esim.py +++ b/system/hardware/tici/tests/test_esim.py @@ -18,24 +18,11 @@ class TestEsim: if not TICI: pytest.skip() - def ensure_profile_deleted(self): - lpa = LPA2() - try: - lpa.delete_profile(self.TEST_ICCID) - except LPAProfileNotFoundError: - pass - assert not self._profile_exists(self.TEST_ICCID, self.TEST_NICKNAME) - def setup_method(self): - self.ensure_profile_deleted() - - # clear out any pending notifications - lpa = LPA2() - lpa.process_notifications() - assert len(lpa.list_notifications()) == 0 + self._cleanup() def teardown_method(self): - self.ensure_profile_deleted() + self._cleanup() def test_list_profiles(self): lpa = LPA2() @@ -44,10 +31,6 @@ class TestEsim: def test_download_profile(self): lpa = LPA2() - try: - lpa.delete_profile(self.TEST_ICCID) - except Exception as e: - print(e) lpa.download_profile(self.TEST_ACTIVATION_CODE, self.TEST_NICKNAME) assert self._profile_exists(self.TEST_ICCID, self.TEST_NICKNAME) @@ -65,6 +48,17 @@ class TestEsim: current = lpa.get_active_profile() assert current is None + def _cleanup(self): + lpa = LPA2() + try: + lpa.delete_profile(self.TEST_ICCID) + except LPAProfileNotFoundError: + pass + assert not self._profile_exists(self.TEST_ICCID, self.TEST_NICKNAME) + lpa = LPA2() + lpa.process_notifications() + assert len(lpa.list_notifications()) == 0 + def _profile_exists(self, iccid: str, nickname: str) -> bool: lpa = LPA2() profiles = lpa.list_profiles()