Fix pylint warnings/errors in cli
[functest.git] / functest / cli / cli_base.py
1 #!/usr/bin/env python
2 #
3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8
9 # pylint: disable=missing-docstring
10
11 import logging.config
12 import pkg_resources
13
14 import click
15
16 from functest.cli.commands.cli_env import CliEnv
17 from functest.cli.commands.cli_os import CliOpenStack
18 from functest.cli.commands.cli_testcase import CliTestcase
19 from functest.cli.commands.cli_tier import CliTier
20
21
22 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
23
24
25 @click.group(context_settings=CONTEXT_SETTINGS)
26 @click.version_option(version='opnfv colorado.0.1 ')
27 def cli():
28     logging.config.fileConfig(pkg_resources.resource_filename(
29         'functest', 'ci/logging.ini'))
30     logging.captureWarnings(True)
31
32
33 ENV = CliEnv()
34 OPENSTACK = CliOpenStack()
35 TESTCASE = CliTestcase()
36 TIER = CliTier()
37
38
39 @cli.group()
40 @click.pass_context
41 def env(ctx):  # pylint: disable=unused-argument
42     pass
43
44
45 @cli.group()
46 @click.pass_context
47 def openstack(ctx):  # pylint: disable=unused-argument
48     pass
49
50
51 @cli.group()
52 @click.pass_context
53 def testcase(ctx):  # pylint: disable=unused-argument
54     pass
55
56
57 @cli.group()
58 @click.pass_context
59 def tier(ctx):  # pylint: disable=unused-argument
60     pass
61
62
63 @openstack.command('check', help="Checks connectivity and status "
64                    "to the OpenStack deployment.")
65 def os_check():
66     OPENSTACK.check()
67
68
69 @openstack.command('show-credentials',
70                    help="Prints the OpenStack credentials.")
71 def os_show_credentials():
72     OPENSTACK.show_credentials()
73
74
75 @env.command('show', help="Shows information about the current environment.")
76 def env_show():
77     ENV.show()
78
79
80 @testcase.command('list', help="Lists the available testcases.")
81 def testcase_list():
82     TESTCASE.list()
83
84
85 @testcase.command('show', help="Shows information about a test case.")
86 @click.argument('testname', type=click.STRING, required=True)
87 def testcase_show(testname):
88     TESTCASE.show(testname)
89
90
91 @testcase.command('run', help="Executes a test case.")
92 @click.argument('testname', type=click.STRING, required=True)
93 @click.option('-n', '--noclean', is_flag=True, default=False,
94               help='The created openstack resources by the test'
95               'will not be cleaned after the execution.')
96 @click.option('-r', '--report', is_flag=True, default=False,
97               help='Push results to the results DataBase. Only CI Pods'
98               'have rights to do that.')
99 def testcase_run(testname, noclean, report):
100     TESTCASE.run(testname, noclean, report)
101
102
103 @tier.command('list', help="Lists the available tiers.")
104 def tier_list():
105     TIER.list()
106
107
108 @tier.command('show', help="Shows information about a tier.")
109 @click.argument('tiername', type=click.STRING, required=True)
110 def tier_show(tiername):
111     TIER.show(tiername)
112
113
114 @tier.command('get-tests', help="Prints the tests in a tier.")
115 @click.argument('tiername', type=click.STRING, required=True)
116 def tier_gettests(tiername):
117     TIER.gettests(tiername)
118
119
120 @tier.command('run', help="Executes all the tests within a tier.")
121 @click.argument('tiername', type=click.STRING, required=True)
122 @click.option('-n', '--noclean', is_flag=True, default=False,
123               help='The created openstack resources by the tests'
124               'will not be cleaned after the execution.')
125 @click.option('-r', '--report', is_flag=True, default=False,
126               help='Push results to the results DataBase. Only CI Pods'
127               'have rights to do that.')
128 def tier_run(tiername, noclean, report):
129     TIER.run(tiername, noclean, report)