Added tests for removing short args in cli

This commit is contained in:
hackrush 2018-02-25 23:27:41 +05:30
parent da4a24d79f
commit 14c01b095b

View file

@ -52,6 +52,7 @@ class TestIntegration(unittest.TestCase):
def tearDownClass(cls): def tearDownClass(cls):
shell_command(['lbrynet-cli', 'daemon_stop']) shell_command(['lbrynet-cli', 'daemon_stop'])
def test_cli(self): def test_cli(self):
help_out,err = lbrynet_cli(['help']) help_out,err = lbrynet_cli(['help'])
self.assertTrue(help_out) self.assertTrue(help_out)
@ -66,6 +67,7 @@ class TestIntegration(unittest.TestCase):
out = json.loads(out) out = json.loads(out)
self.assertTrue(out['is_running']) self.assertTrue(out['is_running'])
def test_cli_docopts(self): def test_cli_docopts(self):
out,err = lbrynet_cli(['cli_test_command']) out,err = lbrynet_cli(['cli_test_command'])
self.assertEqual('',out) self.assertEqual('',out)
@ -92,18 +94,23 @@ class TestIntegration(unittest.TestCase):
# TODO: variable length arguments don't have guess_type() on them # TODO: variable length arguments don't have guess_type() on them
self.assertEqual([1,['2','3'],None,None,False,False], 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,err = lbrynet_cli(['cli_test_command','1','--a_arg'])
out = json.loads(out) out = json.loads(out)
self.assertEqual([1,[],None,None,True,False], out) self.assertEqual([1,[],None,None,True,False], out)
out,err = lbrynet_cli(['cli_test_command','1','-a','-b']) out,err = lbrynet_cli(['cli_test_command','1','--a_arg', '--b_arg'])
out = json.loads(out) out = json.loads(out)
self.assertEqual([1,[],None,None,True,True], out) self.assertEqual([1,[],None,None,True,True], out)
def test_cli_docopts_with_short_args(self):
out,err = lbrynet_cli(['cli_test_command','1','-a'])
self.assertRaises(ValueError, json.loads, out)
out,err = lbrynet_cli(['cli_test_command','1','-a','-b'])
self.assertRaises(ValueError, json.loads, out)
def test_status(self): def test_status(self):
out = lbrynet.status() out = lbrynet.status()
self.assertTrue(out['is_running']) self.assertTrue(out['is_running'])