summaryrefslogtreecommitdiffstats
path: root/tests/test_subcmds_init.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_subcmds_init.py')
-rw-r--r--tests/test_subcmds_init.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_subcmds_init.py b/tests/test_subcmds_init.py
new file mode 100644
index 00000000..3a5ca3c2
--- /dev/null
+++ b/tests/test_subcmds_init.py
@@ -0,0 +1,49 @@
1# Copyright (C) 2020 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Unittests for the subcmds/init.py module."""
16
17import unittest
18
19from subcmds import init
20
21
22class InitCommand(unittest.TestCase):
23 """Check registered all_commands."""
24
25 def setUp(self):
26 self.cmd = init.Init()
27
28 def test_cli_parser_good(self):
29 """Check valid command line options."""
30 ARGV = (
31 [],
32 )
33 for argv in ARGV:
34 opts, args = self.cmd.OptionParser.parse_args(argv)
35 self.cmd.ValidateOptions(opts, args)
36
37 def test_cli_parser_bad(self):
38 """Check invalid command line options."""
39 ARGV = (
40 # Too many arguments.
41 ['asdf'],
42
43 # Conflicting options.
44 ['--mirror', '--archive'],
45 )
46 for argv in ARGV:
47 opts, args = self.cmd.OptionParser.parse_args(argv)
48 with self.assertRaises(SystemExit):
49 self.cmd.ValidateOptions(opts, args)