Skip to content

Commit

Permalink
fix panda tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin committed Dec 13, 2024
1 parent 41fd543 commit b8c0d09
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions tests/safety/hyundai_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,21 @@ def test_set_resume_buttons(self):
"""
SET and RESUME enter controls allowed on their falling edge.
"""
for acc_main_on in (True, False):
self.safety.set_acc_main_on(acc_main_on)
for btn_prev in range(8):
for btn_cur in range(8):
self._rx(self._button_msg(Buttons.NONE))
self.safety.set_controls_allowed(0)
for _ in range(10):
self._rx(self._button_msg(btn_prev))
self.assertFalse(self.safety.get_controls_allowed())

# should enter controls allowed on falling edge and not transitioning to cancel
should_enable = acc_main_on and \
btn_cur != btn_prev and \
btn_cur != Buttons.CANCEL and \
btn_prev in (Buttons.RESUME, Buttons.SET)

self._rx(self._button_msg(btn_cur))
self.assertEqual(should_enable, self.safety.get_controls_allowed())
for btn_prev in range(8):
for btn_cur in range(8):
self._rx(self._button_msg(Buttons.NONE))
self.safety.set_controls_allowed(0)
for _ in range(10):
self._rx(self._button_msg(btn_prev))
self.assertFalse(self.safety.get_controls_allowed())

# should enter controls allowed on falling edge and not transitioning to cancel
should_enable = btn_cur != btn_prev and \
btn_cur != Buttons.CANCEL and \
btn_prev in (Buttons.RESUME, Buttons.SET)

self._rx(self._button_msg(btn_cur))
self.assertEqual(should_enable, self.safety.get_controls_allowed())

def test_cancel_button(self):
self.safety.set_controls_allowed(1)
Expand Down

0 comments on commit b8c0d09

Please sign in to comment.