CLI acommadation to the current test case calling method
[bottlenecks.git] / cli / bottlenecks_cli.py
1 #!/usr/bin/env python
2 ##############################################################################
3 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 import click
12
13 from command_group.testcase import Testcase
14
15 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
16
17
18 @click.group(context_settings=CONTEXT_SETTINGS)
19 @click.version_option(version='0.1')
20 @click.pass_context
21 def main(ctx):
22     """cli for bottlenecks project
23
24        commands:
25        bottlenecks testcase run <testcase>
26     """
27     pass
28
29
30 _testcase = Testcase()
31
32
33 @main.group()
34 @click.pass_context
35 def testcase(ctx):
36     """testcase cli group for bottlenecks project"""
37     pass
38
39
40 @testcase.command('run', help="To execute a test case.")
41 @click.argument('testname', type=click.STRING, required=True)
42 @click.option('-n', '--noclean', is_flag=True, default=False,
43               help='Openstack resources created by the test'
44               'will not be cleaned after the testcase execution.')
45 def testcase_run(testname, noclean):
46     _testcase.run('-c ' + testname, noclean)
47
48
49 _teststory = Testcase()
50
51
52 @main.group()
53 @click.pass_context
54 def teststory(ctx):
55     """teststory cli group for bottlenecks project"""
56     pass
57
58
59 @teststory.command('run', help="To execute a test story.")
60 @click.argument('testname', type=click.STRING, required=True)
61 @click.option('-n', '--noclean', is_flag=True, default=False,
62               help='Openstack resources created by the test'
63               'will not be cleaned after the teststory execution.')
64 def teststory_run(testname, noclean):
65     _testcase.run('-s ' + testname, noclean)