def test_transform(self): for ver in DATAMSG.known_versions: with self.subTest("L1 -> TRX message", ver = ver): msg = DATAMSG_L12TRX(ver = ver) self._test_transform(msg) with self.subTest("TRX -> L1 message", ver = ver): msg = DATAMSG_TRX2L1(ver = ver) self._test_transform(msg)
def test_enc_dec(self): for ver in DATAMSG.known_versions: with self.subTest("L1 -> TRX message", ver = ver): msg = DATAMSG_L12TRX(ver = ver) self._test_enc_dec(msg) with self.subTest("TRX -> L1 message", ver = ver): msg = DATAMSG_TRX2L1(ver = ver) self._test_enc_dec(msg) if ver >= 1: with self.subTest("TRX -> L1 NOPE.ind", ver = ver): msg = DATAMSG_TRX2L1(ver = ver) self._test_enc_dec(msg, nope_ind = True) with self.subTest("TRX -> L1 message (legacy)"): msg = DATAMSG_TRX2L1(ver = 0) self._test_enc_dec(msg, legacy = True)
def test_transform(self): for ver in DATAMSG.KNOWN_VERSIONS: with self.subTest("L1 -> TRX message", ver = ver): msg = DATAMSG_L12TRX(ver = ver) self._test_transform(msg) with self.subTest("TRX -> L1 message", ver = ver): msg = DATAMSG_TRX2L1(ver = ver) self._test_transform(msg)
def test_rand_hdr_burst(self): msg_l12trx = DATAMSG_L12TRX() msg_trx2l1 = DATAMSG_TRX2L1() for i in range(100): msg_l12trx.rand_burst() msg_trx2l1.rand_burst() msg_l12trx.rand_hdr() msg_trx2l1.rand_hdr() msg_l12trx.validate() msg_trx2l1.validate()
def test_validate(self): # Unknown version with self.assertRaises(ValueError): msg = DATAMSG_TRX2L1(fn = 0, tn = 0, ver = 100) msg.validate() # Uninitialized field with self.assertRaises(ValueError): msg = DATAMSG_TRX2L1() msg.validate() with self.assertRaises(ValueError): msg = DATAMSG_TRX2L1(fn = None, tn = 0) msg.validate() # Out-of-range value(s) with self.assertRaises(ValueError): msg = DATAMSG_TRX2L1(fn = -1, tn = 0) msg.validate() with self.assertRaises(ValueError): msg = DATAMSG_TRX2L1(fn = 0, tn = 10) msg.validate()