def test_get_return_type_attributes(self): self.assertEqual([], Attributes.get_return_type_attrs([])) self.assertEqual([], Attributes.get_return_type_attrs(['Class.Method(ServiceName.ClassName,MethodName)'])) self.assertEqual(['Class(ServiceName.ClassName)'], Attributes.get_return_type_attrs(['ReturnType.Class(ServiceName.ClassName)'])) self.assertEqual(['Class(ServiceName.ClassName)'], Attributes.get_return_type_attrs(['Class.Method(ServiceName.ClassName,MethodName)', 'ReturnType.Class(ServiceName.ClassName)'])) self.assertEqual(['List(string)'], Attributes.get_return_type_attrs(['ReturnType.List(string)'])) self.assertEqual(['Dictionary(int32,string)'], Attributes.get_return_type_attrs(['ReturnType.Dictionary(int32,string)'])) self.assertEqual(['Set(string)'], Attributes.get_return_type_attrs(['ReturnType.Set(string)'])) self.assertEqual(['List(Dictionary(int32,string))'], Attributes.get_return_type_attrs(['ReturnType.List(Dictionary(int32,string))'])) self.assertEqual(['Dictionary(int32,List(ServiceName.ClassName))'], Attributes.get_return_type_attrs(['ReturnType.Dictionary(int32,List(ServiceName.ClassName))']))
def get_return_type(self, typ, attrs): """ Return a type object for a return value with the given protocol buffer type and procedure attributes """ attrs = _Attributes.get_return_type_attrs(attrs) for attr in attrs: try: return self.as_type(attr) except ValueError: pass return self.as_type(typ)