From 5fe0c1c41e060ac347ad6c856d38f892f30e6d1a Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Fri, 20 Sep 2024 15:37:25 +0200 Subject: [PATCH] pyln-client: adds testcase for usage in manifest and print_usage --- contrib/pyln-client/tests/test_plugin.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/contrib/pyln-client/tests/test_plugin.py b/contrib/pyln-client/tests/test_plugin.py index 9393269a5efd..9493a20cc78b 100644 --- a/contrib/pyln-client/tests/test_plugin.py +++ b/contrib/pyln-client/tests/test_plugin.py @@ -435,3 +435,22 @@ def test4(request): ba = p._bind_kwargs(test4, {}, req) with pytest.raises(ValueError, match=r'current state is RequestState\.FINISHED(.*\n*.*)*MARKER4'): test4(*ba.args) + + +def test_usage(): + p = Plugin(autopatch=False) + + @p.method("some_method") + def some_method(some_arg: str = None): + """some description""" + pass + + manifest = p._getmanifest() + usage = p.get_usage() + + assert manifest['rpcmethods'][0]['name'] == 'some_method' + assert "some_arg" in manifest['rpcmethods'][0]['usage'] + assert "some description" in manifest['rpcmethods'][0]['usage'] + assert "some_method" in usage + assert "some_arg" in usage + assert "some description" in usage