def test_scan_subclass(self): class MyRoot(WSRoot): class SubClass(object): pass r = MyRoot() api = list(scan_api(r)) assert len(api) == 0
def test_scan_api(self): class NS(object): @expose(int) @validate(int, int) def multiply(self, a, b): return a * b class MyRoot(WSRoot): ns = NS() r = MyRoot() api = list(scan_api(r)) assert len(api) == 1 path, fd, args = api[0] assert path == ['ns', 'multiply'] assert fd._wsme_definition.name == 'multiply' assert args == []
def test_scan_api_too_deep(self): class Loop(object): pass l = Loop() for i in range(0, 21): nl = Loop() nl.l = l l = nl class MyRoot(WSRoot): loop = l r = MyRoot() try: list(scan_api(r)) assert False, "ValueError not raised" except ValueError as e: assert str(e).startswith("Path is too long")