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 absolute_import
15 from yardstick.benchmark.core.testcase import Testcase
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):
40 case_table = prettytable.PrettyTable(['Testcase Name', 'Description'])
41 case_table.align = 'l'
42 for testcase_record in testcase_list:
43 case_table.add_row([testcase_record['Name'], testcase_record['Description']])