def test_parser(self):
parser = cli._get_parser(gitlab.v3.cli)
subparsers = None
for action in parser._actions:
if type(action) == argparse._SubParsersAction:
subparsers = action
break
self.assertIsNotNone(subparsers)
self.assertIn('user', subparsers.choices)
user_subparsers = None
for action in subparsers.choices['user']._actions:
if type(action) == argparse._SubParsersAction:
user_subparsers = action
break
self.assertIsNotNone(user_subparsers)
self.assertIn('list', user_subparsers.choices)
self.assertIn('get', user_subparsers.choices)
self.assertIn('delete', user_subparsers.choices)
self.assertIn('update', user_subparsers.choices)
self.assertIn('create', user_subparsers.choices)
self.assertIn('block', user_subparsers.choices)
self.assertIn('unblock', user_subparsers.choices)
actions = user_subparsers.choices['create']._option_string_actions
self.assertFalse(actions['--twitter'].required)
self.assertTrue(actions['--username'].required)
评论列表
文章目录