def GetAnnotatedMethods(cls): """Returns a dictionary of annotated router methods.""" result = {} # We want methods with the highest call-order to be processed last, # so that their annotations have precedence. for i_cls in reversed(inspect.getmro(cls)): for name in compatibility.ListAttrs(i_cls): cls_method = getattr(i_cls, name) if not callable(cls_method): continue if not hasattr(cls_method, "__http_methods__"): continue result[name] = RouterMethodMetadata( name=name, doc=cls_method.__doc__, args_type=getattr(cls_method, "__args_type__", None), result_type=getattr(cls_method, "__result_type__", None), category=getattr(cls_method, "__category__", None), http_methods=getattr(cls_method, "__http_methods__", set()), no_audit_log_required=getattr(cls_method, "__no_audit_log_required__", False)) return result
def testProperties(self): class Foo(object): BAR = 1 BAZ = 2 attrs = compatibility.ListAttrs(Foo) self.assertIn("BAR", attrs) self.assertIn("BAZ", attrs)
def testMethods(self): class Bar(object): def Quux(self): pass def Thud(self): pass attrs = compatibility.ListAttrs(Bar) self.assertIn("Quux", attrs) self.assertIn("Thud", attrs)