forked from LBRYCommunity/lbry-sdk
add tests for CLI flags
This commit is contained in:
parent
9bf533fc73
commit
a1c99594b3
2 changed files with 26 additions and 8 deletions
|
@ -2501,22 +2501,25 @@ class Daemon(AuthJSONRPCServer):
|
|||
defer.returnValue(response)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def jsonrpc_cli_test_command(self, pos_arg, pos_args=[], pos_arg2=None, pos_arg3=None):
|
||||
@AuthJSONRPCServer.flags(a_arg='-a', b_arg='-b')
|
||||
def jsonrpc_cli_test_command(self, pos_arg, pos_args=[], pos_arg2=None, pos_arg3=None,
|
||||
a_arg=False, b_arg=False):
|
||||
"""
|
||||
This command is only for testing the CLI argument parsing
|
||||
Usage:
|
||||
cli_test_command (<pos_arg> | --pos_arg=<pos_arg>)
|
||||
cli_test_command [-a] [-b] (<pos_arg> | --pos_arg=<pos_arg>)
|
||||
[<pos_args>...] [--pos_arg2=<pos_arg2>]
|
||||
[--pos_arg3=<pos_arg3>]
|
||||
|
||||
Options:
|
||||
-a, --a_arg : a arg
|
||||
-b, --b_arg : b arg
|
||||
<pos_arg2>, --pos_arg2=<pos_arg2> : pos arg 2
|
||||
<pos_arg3>, --pos_arg3=<pos_arg3> : pos arg 3
|
||||
|
||||
Returns:
|
||||
pos args
|
||||
"""
|
||||
out = (pos_arg, pos_args, pos_arg2, pos_arg3)
|
||||
out = (pos_arg, pos_args, pos_arg2, pos_arg3, a_arg, b_arg)
|
||||
response = yield self._render_response(out)
|
||||
defer.returnValue(response)
|
||||
|
||||
|
|
|
@ -77,21 +77,36 @@ class TestIntegration(unittest.TestCase):
|
|||
|
||||
out,err = lbrynet_cli(['cli_test_command','1'])
|
||||
out = json.loads(out)
|
||||
self.assertEqual([1,[],None,None], out)
|
||||
self.assertEqual([1,[],None,None,False,False], out)
|
||||
|
||||
out,err = lbrynet_cli(['cli_test_command','1','--pos_arg2=1'])
|
||||
out = json.loads(out)
|
||||
self.assertEqual([1,[],1,None], out)
|
||||
self.assertEqual([1,[],1,None,False,False], out)
|
||||
|
||||
|
||||
out,err = lbrynet_cli(['cli_test_command','1', '--pos_arg2=2','--pos_arg3=3'])
|
||||
out = json.loads(out)
|
||||
self.assertEqual([1,[],2,3], out)
|
||||
self.assertEqual([1,[],2,3,False,False], out)
|
||||
|
||||
out,err = lbrynet_cli(['cli_test_command','1','2','3'])
|
||||
out = json.loads(out)
|
||||
# TODO: variable length arguments don't have guess_type() on them
|
||||
self.assertEqual([1,['2','3'],None,None], out)
|
||||
self.assertEqual([1,['2','3'],None,None,False,False], out)
|
||||
|
||||
|
||||
out,err = lbrynet_cli(['cli_test_command','1','-a'])
|
||||
out = json.loads(out)
|
||||
self.assertEqual([1,[],None,None,True,False], out)
|
||||
|
||||
out,err = lbrynet_cli(['cli_test_command','1','--a_arg'])
|
||||
out = json.loads(out)
|
||||
self.assertEqual([1,[],None,None,True,False], out)
|
||||
|
||||
|
||||
out,err = lbrynet_cli(['cli_test_command','1','-a','-b'])
|
||||
out = json.loads(out)
|
||||
self.assertEqual([1,[],None,None,True,True], out)
|
||||
|
||||
|
||||
|
||||
def test_status(self):
|
||||
|
|
Loading…
Reference in a new issue