示例#1
0
    def test_new_encode(self):
        """ Check encoding using new generic method """
        pdu = P_DATA_TF()
        pdu.Decode(p_data_tf)
        s = pdu.encode()

        self.assertEqual(s, p_data_tf)
示例#2
0
    def test_generic_encode(self):
        """ Check using the new pdu.encode produces the correct output """
        pdu = P_DATA_TF()
        pdu.Decode(p_data_tf)
        s = pdu.Encode()
        t = pdu.encode()

        self.assertEqual(s, t)
    def test_conversion(self):
        """ Check conversion to a PDU produces the correct output """
        primitive = P_DATA()
        pdv = b"\x03\x00\x00\x00\x00" \
              b"\x04\x00\x00\x00\x42\x00\x00\x00\x00\x00\x02\x00\x12\x00\x00" \
              b"\x00\x31\x2e\x32\x2e\x38\x34\x30\x2e\x31\x30\x30\x30\x38\x2e" \
              b"\x31\x2e\x31\x00\x00\x00\x00\x01\x02\x00\x00\x00\x30\x80\x00" \
              b"\x00\x20\x01\x02\x00\x00\x00\x01\x00\x00\x00\x00\x08\x02\x00" \
              b"\x00\x00\x01\x01\x00\x00\x00\x09\x02\x00\x00\x00\x00\x00"
        primitive.presentation_data_value_list = [[1, pdv]]

        pdu = P_DATA_TF()
        pdu.from_primitive(primitive)
        data = pdu.encode()

        self.assertEqual(data,
                         b"\x04\x00\x00\x00\x00\x54\x00\x00\x00\x50\x01" + pdv)
示例#4
0
    def test_encode(self):
        """ Check encoding an p_data produces the correct output """
        pdu = P_DATA_TF()
        pdu.decode(p_data_tf)

        assert pdu.encode() == p_data_tf