Esempio n. 1
0
    def test_verify_length_3(self):
        stream = easyb.message.stream.Stream(Length.Byte3)

        stream._data = []

        check1 = stream.verify_length()

        self.assertFalse(check1)
        return
Esempio n. 2
0
    def test_verify_length_1(self):
        stream = easyb.message.stream.Stream(Length.Byte3)

        stream.data[0] = 1
        stream.data[1] = 0
        stream.data[2] = 0

        check1 = stream.verify_length()

        self.assertTrue(check1)
        return
Esempio n. 3
0
    def test_decode_1(self):
        header = [0xfe, 0x05, 0x26]

        stream = easyb.message.stream.Stream(Length.Byte3)

        check1 = stream.decode(bytes(header))
        check2 = stream.verify_length()

        self.assertTrue(check1)
        self.assertTrue(check2)
        self.assertEqual(stream.data, header)
        return
Esempio n. 4
0
    def test_verify_length_2(self):
        stream = easyb.message.stream.Stream(Length.Byte3)

        stream.data[0] = 1
        stream.data[1] = 0
        stream.data[2] = 0

        stream.data.append(0)

        check1 = stream.verify_length()

        self.assertFalse(check1)
        return
Esempio n. 5
0
    def test_set_data_1(self):
        header = [0xfe, 0x05, 0x26]
        data = [0x71, 0x00, 0x48, 0xe3, 0x54, 0x28]
        all_data = [0xfe, 0x05, 0x26, 0x71, 0x00, 0x48, 0xe3, 0x54, 0x28]

        stream = easyb.message.stream.Stream(Length.Byte3)

        check1 = stream.decode(bytes(header))
        check2 = stream.verify_length()

        self.assertTrue(check1)
        self.assertTrue(check2)
        self.assertEqual(stream.data, header)

        stream.append(bytes(data))
        stream.length = Length.Byte9

        check3 = stream.verify_length()
        check4 = stream.verify_crc()

        self.assertTrue(check3)
        self.assertTrue(check4)
        self.assertEqual(stream.data, all_data)
        return
Esempio n. 6
0
    def test_verify_length_6(self):
        stream = easyb.message.stream.Stream(Length.Byte9)

        stream.data[0] = 1
        stream.data[1] = 0
        stream.data[2] = 0
        stream.data[3] = 1
        stream.data[4] = 0
        stream.data[5] = 0
        stream.data[6] = 1
        stream.data[7] = 0
        stream.data[8] = 0

        stream.data.append(1)
        stream.data.append(0)
        stream.data.append(0)

        check1 = stream.verify_length()

        self.assertFalse(check1)
        return