assert expected openpilot undefined message behavior (#1050)

assert expected openpilot behavior
This commit is contained in:
Shane Smiskol 2024-06-05 23:08:15 -07:00 committed by GitHub
parent dfaa27d313
commit f58bc3392c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 0 deletions

View File

@ -382,6 +382,18 @@ class TestCanParserPacker(unittest.TestCase):
with self.assertRaises(RuntimeError): with self.assertRaises(RuntimeError):
CANParser("toyota_nodsu_pt_generated", [("ACC_CONTROL", 10), ("ACC_CONTROL", 10)]) CANParser("toyota_nodsu_pt_generated", [("ACC_CONTROL", 10), ("ACC_CONTROL", 10)])
def test_allow_undefined_msgs(self):
# TODO: we should throw an exception for these, but we need good
# discovery tests in openpilot first
packer = CANPacker("toyota_nodsu_pt_generated")
self.assertEqual(packer.make_can_msg("ACC_CONTROL", 0, {"UNKNOWN_SIGNAL": 0}),
[835, 0, b'\x00\x00\x00\x00\x00\x00\x00N', 0])
self.assertEqual(packer.make_can_msg("UNKNOWN_MESSAGE", 0, {"UNKNOWN_SIGNAL": 0}),
[0, 0, b'', 0])
self.assertEqual(packer.make_can_msg(0, 0, {"UNKNOWN_SIGNAL": 0}),
[0, 0, b'', 0])
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()