|
31 | 31 |
|
32 | 32 | fromgitlabimportcli
|
33 | 33 | importgitlab.v3.cli
|
| 34 | +importgitlab.v4.cli |
34 | 35 |
|
35 | 36 |
|
36 | 37 | classTestCLI(unittest.TestCase):
|
@@ -86,6 +87,42 @@ def test_base_parser(self):
|
86 | 87 | self.assertEqual(args.config_file, ['foo.cfg','bar.cfg'])
|
87 | 88 |
|
88 | 89 |
|
| 90 | +classTestV4CLI(unittest.TestCase): |
| 91 | +deftest_parse_args(self): |
| 92 | +parser=cli._get_parser(gitlab.v4.cli) |
| 93 | +args=parser.parse_args(['project','list']) |
| 94 | +self.assertEqual(args.what,'project') |
| 95 | +self.assertEqual(args.action,'list') |
| 96 | + |
| 97 | +deftest_parser(self): |
| 98 | +parser=cli._get_parser(gitlab.v4.cli) |
| 99 | +subparsers=None |
| 100 | +foractioninparser._actions: |
| 101 | +iftype(action)==argparse._SubParsersAction: |
| 102 | +subparsers=action |
| 103 | +break |
| 104 | +self.assertIsNotNone(subparsers) |
| 105 | +self.assertIn('project',subparsers.choices) |
| 106 | + |
| 107 | +user_subparsers=None |
| 108 | +foractioninsubparsers.choices['project']._actions: |
| 109 | +iftype(action)==argparse._SubParsersAction: |
| 110 | +user_subparsers=action |
| 111 | +break |
| 112 | +self.assertIsNotNone(user_subparsers) |
| 113 | +self.assertIn('list',user_subparsers.choices) |
| 114 | +self.assertIn('get',user_subparsers.choices) |
| 115 | +self.assertIn('delete',user_subparsers.choices) |
| 116 | +self.assertIn('update',user_subparsers.choices) |
| 117 | +self.assertIn('create',user_subparsers.choices) |
| 118 | +self.assertIn('archive',user_subparsers.choices) |
| 119 | +self.assertIn('unarchive',user_subparsers.choices) |
| 120 | + |
| 121 | +actions=user_subparsers.choices['create']._option_string_actions |
| 122 | +self.assertFalse(actions['--description'].required) |
| 123 | +self.assertTrue(actions['--name'].required) |
| 124 | + |
| 125 | + |
89 | 126 | classTestV3CLI(unittest.TestCase):
|
90 | 127 | deftest_parse_args(self):
|
91 | 128 | parser=cli._get_parser(gitlab.v3.cli)
|
|