Exemplo n.º 1
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.assertEquals(13, len(spec_input))
        self.assertEquals("STRTE\x01\xff\x80C\x01\x7f\r\n", spec_input)
Exemplo n.º 2
0
    def test_output_wiht_crc(self):
        """ Test crc and is_crc functions. """
        field = Field.crc()

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

        field = Field.padding(1)
        self.assertFalse(Field.is_crc(field))