def test_not_whitelist(self):
     msg = "0x89,0x30,0x33"
     parser.whitelist = [0x39]
     with captured_output() as (sout, serr):
         parser.parse_message(msg)
     out = sout.getvalue().strip()
     self.assertFalse("PID 0x39" in out)
     self.assertFalse("MID 0x89" in out)
 def test_json(self):
     parser.do_json = True
     parser.pdelim = False
     parser.pregular = False
     msg = "0x89,0x30,0x33"
     with captured_output() as (sout, serr):
         parser.parse_message(msg)
     jmsg = json.loads(sout.getvalue().strip())
     self.assertTrue("PID_DEF" in jmsg["DATA"][str(0x30)])
 def test_json_checksum(self):
     parser.do_json = True
     parser.pdelim = False
     parser.pregular = False
     parser.checksums = True
     msg = "0x89,0x30,0x33,0x2d"
     with captured_output() as (sout, serr):
         parser.parse_message(msg)
     jmsg = json.loads(sout.getvalue().strip())
     self.assertTrue("CLC_CHECKSUM" in jmsg)
     self.assertTrue(jmsg["CLC_CHECKSUM"] == 20)
 def test_J1708(self):
     msg = "17,0a,0a,0a"
     with captured_output() as (sout, serr):
         parser.parse_message(msg)
     self.assertTrue("TRANSMISSION" in sout.getvalue().strip())
 def test_special_pid_var_len(self):
     msg = "87,d3,2,c2,c1,d3,1,c2,c0,bf,cf,df"
     with captured_output() as (sout, serr):
         parser.parse_message(msg)
     self.assertTrue(sout.getvalue().strip().count("PID 0xd3") == 2)
 def test_whitelist(self):
     msg = "0x89,0x30,0x33"
     parser.whitelist = [0x30]
     with captured_output() as (sout, serr):
         parser.parse_message(msg)
     self.assertTrue("PID 0x30" in sout.getvalue())