Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit88391bf

Browse files
author
Gauvain Pocentek
committed
Add basic unit tests for v4 CLI
1 parent7c6be94 commit88391bf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎gitlab/tests/test_cli.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
fromgitlabimportcli
3333
importgitlab.v3.cli
34+
importgitlab.v4.cli
3435

3536

3637
classTestCLI(unittest.TestCase):
@@ -86,6 +87,42 @@ def test_base_parser(self):
8687
self.assertEqual(args.config_file, ['foo.cfg','bar.cfg'])
8788

8889

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+
89126
classTestV3CLI(unittest.TestCase):
90127
deftest_parse_args(self):
91128
parser=cli._get_parser(gitlab.v3.cli)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp