Add clear DTC codes button to Pi DTC page (FEAT-15)
This commit is contained in:
@@ -62,6 +62,22 @@ class DtcPersistenceTest(unittest.TestCase):
|
||||
self.assertEqual(app_sql.count_active_dtcs(), 0)
|
||||
self.assertIs(app_sql.get_persisted_dtc_state()["mil"], False)
|
||||
|
||||
def test_clear_dtc_state_clears_active_and_mil(self):
|
||||
app_sql.save_dtc_state(True, [
|
||||
{"code": "P0300", "description": "Random misfire"},
|
||||
{"code": "P0420", "description": "Catalyst efficiency"},
|
||||
])
|
||||
app_sql.clear_dtc_state()
|
||||
state = app_sql.get_persisted_dtc_state()
|
||||
self.assertIs(state["mil"], False)
|
||||
self.assertEqual(state["codes"], [])
|
||||
self.assertEqual(app_sql.count_active_dtcs(), 0)
|
||||
# History rows are kept but no longer set.
|
||||
rows = self.conn.execute(
|
||||
"SELECT code, IS_SET FROM dtc ORDER BY code"
|
||||
).fetchall()
|
||||
self.assertEqual(rows, [("P0300", 0), ("P0420", 0)])
|
||||
|
||||
def test_first_seen_preserved_while_last_seen_bumps(self):
|
||||
first = datetime(2026, 2, 1, 8, 0, 0)
|
||||
later = datetime(2026, 2, 1, 8, 5, 0)
|
||||
|
||||
Reference in New Issue
Block a user