def test_normalized_lookup(self): key_type = lookup_casstype('MapType(UTF8Type, Int32Type)') protocol_version = 3 om = OrderedMapSerializedKey(key_type, protocol_version) key_ascii = {'one': 1} key_unicode = {u'two': 2} om._insert_unchecked(key_ascii, key_type.serialize(key_ascii, protocol_version), object()) om._insert_unchecked(key_unicode, key_type.serialize(key_unicode, protocol_version), object()) # type lookup is normalized by key_type # PYTHON-231 self.assertIs(om[{'one': 1}], om[{u'one': 1}]) self.assertIs(om[{'two': 2}], om[{u'two': 2}]) self.assertIsNot(om[{'one': 1}], om[{'two': 2}])
(b'\x7f\xff\xff\xff\xff\xff\xff\xff', 'LongType', 9223372036854775807), (b'\x80\x00\x00\x00\x00\x00\x00\x00', 'LongType', -9223372036854775808), (b'', 'LongType', None), (b'', 'InetAddressType', None), (b'A46\xa9', 'InetAddressType', '65.52.54.169'), (b'*\x00\x13(\xe1\x02\xcc\xc0\x00\x00\x00\x00\x00\x00\x01"', 'InetAddressType', '2a00:1328:e102:ccc0::122'), (b'\xe3\x81\xbe\xe3\x81\x97\xe3\x81\xa6', 'UTF8Type', u'\u307e\u3057\u3066'), (b'\xe3\x81\xbe\xe3\x81\x97\xe3\x81\xa6' * 1000, 'UTF8Type', u'\u307e\u3057\u3066' * 1000), (b'', 'UTF8Type', u''), (b'\xff' * 16, 'UUIDType', UUID('ffffffff-ffff-ffff-ffff-ffffffffffff')), (b'I\x15~\xfc\xef<\x9d\xe3\x16\x98\xaf\x80\x1f\xb4\x0b*', 'UUIDType', UUID('49157efc-ef3c-9de3-1698-af801fb40b2a')), (b'', 'UUIDType', None), (b'', 'MapType(AsciiType, BooleanType)', None), (b'', 'ListType(FloatType)', None), (b'', 'SetType(LongType)', None), (b'\x00\x00', 'MapType(DecimalType, BooleanType)', OrderedMapSerializedKey(DecimalType, 0)), (b'\x00\x00', 'ListType(FloatType)', []), (b'\x00\x00', 'SetType(IntegerType)', sortedset()), (b'\x00\x01\x00\x10\xafYC\xa3\xea<\x11\xe1\xabc\xc4,\x03"y\xf0', 'ListType(TimeUUIDType)', [UUID(bytes=b'\xafYC\xa3\xea<\x11\xe1\xabc\xc4,\x03"y\xf0')]), (b'\x80\x00\x00\x01', 'SimpleDateType', Date(1)), (b'\x7f\xff\xff\xff', 'SimpleDateType', Date('1969-12-31')), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'TimeType', Time(1)), (b'\x7f', 'ByteType', 127), (b'\x80', 'ByteType', -128), (b'\x7f\xff', 'ShortType', 32767), (b'\x80\x00', 'ShortType', -32768) ) ordered_map_value = OrderedMapSerializedKey(UTF8Type, 2) ordered_map_value._insert(u'\u307fbob', 199) ordered_map_value._insert(u'', -1)
def test_init(self): om = OrderedMapSerializedKey(UTF8Type, 2) self.assertEqual(om, {})
(b'*\x00\x13(\xe1\x02\xcc\xc0\x00\x00\x00\x00\x00\x00\x01"', 'InetAddressType', '2a00:1328:e102:ccc0::122'), (b'\xe3\x81\xbe\xe3\x81\x97\xe3\x81\xa6', 'UTF8Type', u'\u307e\u3057\u3066'), (b'\xe3\x81\xbe\xe3\x81\x97\xe3\x81\xa6' * 1000, 'UTF8Type', u'\u307e\u3057\u3066' * 1000), (b'', 'UTF8Type', u''), (b'\xff' * 16, 'UUIDType', UUID('ffffffff-ffff-ffff-ffff-ffffffffffff')), (b'I\x15~\xfc\xef<\x9d\xe3\x16\x98\xaf\x80\x1f\xb4\x0b*', 'UUIDType', UUID('49157efc-ef3c-9de3-1698-af801fb40b2a')), (b'', 'UUIDType', None), (b'', 'MapType(AsciiType, BooleanType)', None), (b'', 'ListType(FloatType)', None), (b'', 'SetType(LongType)', None), (b'\x00\x00', 'MapType(DecimalType, BooleanType)', OrderedMapSerializedKey(DecimalType, 0)), (b'\x00\x00', 'ListType(FloatType)', []), (b'\x00\x00', 'SetType(IntegerType)', sortedset()), (b'\x00\x01\x00\x10\xafYC\xa3\xea<\x11\xe1\xabc\xc4,\x03"y\xf0', 'ListType(TimeUUIDType)', [UUID(bytes=b'\xafYC\xa3\xea<\x11\xe1\xabc\xc4,\x03"y\xf0')]), (b'\x80\x00\x00\x01', 'SimpleDateType', Date(1)), (b'\x7f\xff\xff\xff', 'SimpleDateType', Date('1969-12-31')), (b'\x00\x00\x00\x00\x00\x00\x00\x01', 'TimeType', Time(1)), (b'\x7f', 'ByteType', 127), (b'\x80', 'ByteType', -128), (b'\x7f\xff', 'ShortType', 32767), (b'\x80\x00', 'ShortType', -32768)) ordered_map_value = OrderedMapSerializedKey(UTF8Type, 2) ordered_map_value._insert(u'\u307fbob', 199)