def test_dictionary_types(self): types = Types() typ = types.dictionary_type(types.string_type, types.uint32_type) self.assertTrue(isinstance(typ, DictionaryType)) self.assertEqual(typ.python_type, dict) self.check_protobuf_type(Type.DICTIONARY, '', '', 2, typ.protobuf_type) self.check_protobuf_type(Type.STRING, '', '', 0, typ.protobuf_type.types[0]) self.check_protobuf_type(Type.UINT32, '', '', 0, typ.protobuf_type.types[1]) self.assertTrue(isinstance(typ.key_type, ValueType)) self.assertEqual(str, typ.key_type.python_type) self.check_protobuf_type(Type.STRING, '', '', 0, typ.key_type.protobuf_type) self.assertTrue(isinstance(typ.value_type, ValueType)) self.assertEqual(int, typ.value_type.python_type) self.check_protobuf_type(Type.UINT32, '', '', 0, typ.value_type.protobuf_type)
def test_dictionary_types(self): types = Types() typ = types.dictionary_type(types.string_type, types.uint32_type) self.assertTrue(isinstance(typ, DictionaryType)) self.assertEqual(typ.python_type, dict) self.check_protobuf_type( Type.DICTIONARY, '', '', 2, typ.protobuf_type) self.check_protobuf_type( Type.STRING, '', '', 0, typ.protobuf_type.types[0]) self.check_protobuf_type( Type.UINT32, '', '', 0, typ.protobuf_type.types[1]) self.assertTrue(isinstance(typ.key_type, ValueType)) self.assertEqual(str, typ.key_type.python_type) self.check_protobuf_type( Type.STRING, '', '', 0, typ.key_type.protobuf_type) self.assertTrue(isinstance(typ.value_type, ValueType)) self.assertEqual(int, typ.value_type.python_type) self.check_protobuf_type( Type.UINT32, '', '', 0, typ.value_type.protobuf_type)