controls: preEnabled doesn't consider noEntry (#26627)

preEnabled doesn't consider noEntry
old-commit-hash: 8ad8d4e1c2887bcd22ab7048960ed6a1a7f8e3f6
This commit is contained in:
Shane Smiskol
2022-11-29 13:11:03 -08:00
committed by GitHub
parent d6f6b0de91
commit 76e7a45284
2 changed files with 4 additions and 7 deletions
+1 -4
View File
@@ -518,10 +518,7 @@ class Controls:
# PRE ENABLING
elif self.state == State.preEnabled:
if self.events.any(ET.NO_ENTRY):
self.state = State.disabled
self.current_alert_types.append(ET.NO_ENTRY)
elif not self.events.any(ET.PRE_ENABLE):
if not self.events.any(ET.PRE_ENABLE):
self.state = State.enabled
else:
self.current_alert_types.append(ET.PRE_ENABLE)
@@ -79,7 +79,7 @@ class TestStateMachine(unittest.TestCase):
self.assertEqual(self.controlsd.state, State.disabled)
def test_no_entry(self):
# disabled with enable events
# Make sure noEntry keeps us disabled
for et in ENABLE_EVENT_TYPES:
self.controlsd.events.add(make_event([ET.NO_ENTRY, et]))
self.controlsd.state_transition(self.CS)
@@ -87,11 +87,11 @@ class TestStateMachine(unittest.TestCase):
self.controlsd.events.clear()
def test_no_entry_pre_enable(self):
# preEnabled with preEnabled event
# preEnabled with noEntry event
self.controlsd.state = State.preEnabled
self.controlsd.events.add(make_event([ET.NO_ENTRY, ET.PRE_ENABLE]))
self.controlsd.state_transition(self.CS)
self.assertEqual(self.controlsd.state, State.disabled)
self.assertEqual(self.controlsd.state, State.preEnabled)
def test_maintain_states(self):
# Given current state's event type, we should maintain state