From f58bc3392cfffd25b311e093aa72f0ef3a89f6e8 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 5 Jun 2024 23:08:15 -0700 Subject: [PATCH] assert expected openpilot undefined message behavior (#1050) assert expected openpilot behavior --- can/tests/test_packer_parser.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/can/tests/test_packer_parser.py b/can/tests/test_packer_parser.py index 79f24ec5..c313805c 100755 --- a/can/tests/test_packer_parser.py +++ b/can/tests/test_packer_parser.py @@ -382,6 +382,18 @@ class TestCanParserPacker(unittest.TestCase): with self.assertRaises(RuntimeError): 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__": unittest.main()