def test_pack_uuid(): assert Buffer.pack_uuid(UUID.from_bytes(uuid_vector)) == uuid_vector
def test_uuid_from_bytes_to_hex(): uuid = UUID.from_bytes(bytes_vector) assert isinstance(uuid, UUID) assert uuid.to_hex() == hex_vector assert uuid.to_hex(False) == hex_vector.replace("-", "")
entity_metadata_vectors = [ (OrderedDict( (((0, 0), 0), ((1, 1), 1), ((2, 2), 2.0), ((3, 3), u'three'), ((4, 4), Message({'text': u'four'})), ((5, 5), Message({'text': u'five'})), ((6, 6), { 'count': 1, 'item': 267, 'tag': TagRoot({}) }), ((7, 7), True), ((8, 8), (7.699999809265137, 7.699999809265137, 7.699999809265137)), ((9, 9), (8, 8, 8)), ((10, 10), (9, 9, 9)), ((11, 11), 10), ((12, 12), UUID.from_bytes(uuid_vector)), ((13, 13), 12), ((14, 14), TagRoot({u'foo': TagString(u'bar')})))), b'\x00\x00\x00' b'\x01\x01\x01' b'\x02\x02\x40\x00\x00\x00' b'\x03\x03\x05three' b'\x04\x04\x10{"text": "four"}' b'\x05\x05\x01\x10{"text": "five"}' b'\x06\x06\x01\x0b\x01\x00' b'\x07\x07\x01' b'\x08\x08\x40\xf6\x66\x66\x40\xf6\x66\x66\x40\xf6\x66\x66' b'\x09\x09\x00\x00\x02\x00\x20\x00\x00\x08' b'\x0a\x0a\x01\x00\x00\x02\x40\x24\x00\x00\x09' b'\x0b\x0b\x0a' b'\x0c\x0c\x01' + uuid_vector + b'\x0d\x0d\x0c' b'\x0e\x0e\x08\x00\x03foo\x00\x03bar' b'\xff')
def unpack_uuid(self): """ Unpacks a UUID. """ return UUID.from_bytes(self.read(16))