Adding cli for listing all tests in all scenarios

Change-Id: I8543992099e0a5a858509f547ce9dffa42a1f608
This commit is contained in:
Anand Shanmugam 2016-04-20 00:15:26 -07:00
parent 068baf9792
commit 53bb70e3f6
4 changed files with 20 additions and 12 deletions

View File

@ -186,14 +186,14 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
print(encodeutils.safe_encode(pt.get_string(**kwargs)))
def print_dict(dct, dict_property="Property", wrap=0):
def print_dict(dct, dict_property="Property", dict_value="Value", wrap=0):
"""Print a `dict` as a table of two columns.
:param dct: `dict` to print
:param dict_property: name of the first column
:param wrap: wrapping for the second column
"""
pt = prettytable.PrettyTable([dict_property, 'Value'])
pt = prettytable.PrettyTable([dict_property, dict_value])
pt.align = 'l'
for k, v in six.iteritems(dct):
# convert dict to str to check length

View File

@ -18,7 +18,14 @@ import six
from six.moves.urllib import parse
class HealthCheckTest(base.Resource):
def __repr__(self):
return str(self._info)
class HealthCheck(base.Resource):
def __repr__(self):
return "<Cpulse %s>" % self._info
@ -62,3 +69,6 @@ class HealthCheckManager(base.Manager):
return self._list(self._path(id))[0]
except IndexError:
return None
def get_test_list(self):
return self._list(self._path('list_tests'), obj_class=HealthCheckTest)

View File

@ -44,15 +44,6 @@ def do_result(cs, args):
@utils.arg('name',
metavar='<name>',
help='Name of the healthcheck to run')
@utils.arg('--extension',
metavar='<extension>',
help='Name of the health check extension.')
@utils.arg('--test-args',
metavar='<KEY1=VALUE1;KEY2=VALUE2...>',
help='Arguments in key,value pair for the health check extension.')
@utils.arg('--args-file',
metavar='<FILE>',
help='Path to the file which is needed by the extension.')
def do_run(cs, args):
"""Run new test"""
opts = {}
@ -72,6 +63,13 @@ def do_show(cs, args):
utils.print_dict(healthcheck._info)
def do_test_list(cs, args):
"""Show a list of scenarios and tests in each scenario"""
healthcheck = cs.healthcheck.get_test_list()
utils.print_dict(
healthcheck[0]._info, dict_property="Scenarios", dict_value="Tests")
@utils.arg('cpulse',
metavar='<cpulse>',
nargs='+',

View File

@ -5,7 +5,7 @@ skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
install_command = pip install {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt