1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
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 ##############################################################################
10 """ Handler for yardstick command 'testcase' """
11 from __future__ import print_function
12 from __future__ import absolute_import
14 from yardstick.benchmark.core.testcase import Testcase
15 from yardstick.benchmark.core import print_hbar
16 from yardstick.common.utils import cliargs
17 from yardstick.cmd.commands import change_osloobj_to_paras
18 from yardstick.cmd.commands import Commands
21 class TestcaseCommands(Commands):
24 Set of commands to discover and display test cases.
27 def do_list(self, args):
28 """List existing test cases"""
29 testcase_list = self.client.get('/yardstick/testcases')['result']
30 self._format_print(testcase_list)
32 @cliargs("casename", type=str, help="test case name", nargs=1)
33 def do_show(self, args):
34 """Show details of a specific test case"""
35 param = change_osloobj_to_paras(args)
36 Testcase().show(param)
38 def _format_print(self, testcase_list):
42 print("| %-21s | %-60s" % ("Testcase Name", "Description"))
44 for testcase_record in testcase_list:
45 print("| %-16s | %-60s" % (testcase_record['Name'],
46 testcase_record['Description']))