예제 #1
0
    def test_output_wiht_crc(self):
        """ Test crc and is_crc functions. """
        field = Field.crc()

        self.assertEqual('crc', field.name)
        self.assertTrue(Field.is_crc(field))

        field = Field.padding(1)
        self.assertFalse(Field.is_crc(field))
예제 #2
0
    def test_input_with_crc(self):
        """ Test encoding with crc. """
        spec = MasterCommandSpec(
            'TE', [Field.byte('one'),
                   Field.byte('two'),
                   Field.crc()], [])
        spec_input = spec.create_input(1, {"one": 255, "two": 128})

        self.assertEqual(13, len(spec_input))
        self.assertEqual(bytearray(b'STRTE\x01\xff\x80C\x01\x7f\r\n'),
                         spec_input)