def test_describe(): registry = Registry() @registry.method(returns=str, x=int, y=str) def foo(x, y): return str(x) + y foo_desc = {'params': [{'type': 'int', 'name': 'x'}, {'type': 'str', 'name': 'y'}], 'name': 'test_registry.foo', 'returns': 'str', 'description': None} describe_desc = {'params': [], 'name': 'rpc.describe', 'returns': 'dict', 'description': registry.describe.__doc__} assert registry.describe()["methods"] == [describe_desc, foo_desc] docstring = "This is a test." @registry.method(returns=int, a=int, b=int) def bar(a, b): return a + b bar.__doc__ = docstring bar_desc = {'params': [{'type': 'int', 'name': 'a'}, {'type': 'int', 'name': 'b'}], 'name': 'test_registry.bar', 'returns': 'int', 'description': docstring} assert registry.describe()["methods"] == [describe_desc, bar_desc, foo_desc]
def test_describe(): registry = Registry() @registry.method(returns=str, x=int, y=str) def foo(x, y): return str(x) + y foo_desc = { 'params': [{ 'type': 'int', 'name': 'x' }, { 'type': 'str', 'name': 'y' }], 'name': 'test_registry.foo', 'returns': 'str', 'description': None } describe_desc = { 'params': [], 'name': 'rpc.describe', 'returns': 'dict', 'description': registry.describe.__doc__ } assert registry.describe()["methods"] == [describe_desc, foo_desc] docstring = "This is a test." @registry.method(returns=int, a=int, b=int) def bar(a, b): return a + b bar.__doc__ = docstring bar_desc = { 'params': [{ 'type': 'int', 'name': 'a' }, { 'type': 'int', 'name': 'b' }], 'name': 'test_registry.bar', 'returns': 'int', 'description': docstring } assert registry.describe()["methods"] == [ describe_desc, bar_desc, foo_desc ]