Adding cli for listing all tests in all scenarios
Change-Id: I8543992099e0a5a858509f547ce9dffa42a1f608
This commit is contained in:
parent
068baf9792
commit
53bb70e3f6
@ -186,14 +186,14 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
|
|||||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)))
|
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.
|
"""Print a `dict` as a table of two columns.
|
||||||
|
|
||||||
:param dct: `dict` to print
|
:param dct: `dict` to print
|
||||||
:param dict_property: name of the first column
|
:param dict_property: name of the first column
|
||||||
:param wrap: wrapping for the second column
|
:param wrap: wrapping for the second column
|
||||||
"""
|
"""
|
||||||
pt = prettytable.PrettyTable([dict_property, 'Value'])
|
pt = prettytable.PrettyTable([dict_property, dict_value])
|
||||||
pt.align = 'l'
|
pt.align = 'l'
|
||||||
for k, v in six.iteritems(dct):
|
for k, v in six.iteritems(dct):
|
||||||
# convert dict to str to check length
|
# convert dict to str to check length
|
||||||
|
@ -18,7 +18,14 @@ import six
|
|||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
|
|
||||||
|
class HealthCheckTest(base.Resource):
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return str(self._info)
|
||||||
|
|
||||||
|
|
||||||
class HealthCheck(base.Resource):
|
class HealthCheck(base.Resource):
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Cpulse %s>" % self._info
|
return "<Cpulse %s>" % self._info
|
||||||
|
|
||||||
@ -62,3 +69,6 @@ class HealthCheckManager(base.Manager):
|
|||||||
return self._list(self._path(id))[0]
|
return self._list(self._path(id))[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_test_list(self):
|
||||||
|
return self._list(self._path('list_tests'), obj_class=HealthCheckTest)
|
||||||
|
@ -44,15 +44,6 @@ def do_result(cs, args):
|
|||||||
@utils.arg('name',
|
@utils.arg('name',
|
||||||
metavar='<name>',
|
metavar='<name>',
|
||||||
help='Name of the healthcheck to run')
|
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):
|
def do_run(cs, args):
|
||||||
"""Run new test"""
|
"""Run new test"""
|
||||||
opts = {}
|
opts = {}
|
||||||
@ -72,6 +63,13 @@ def do_show(cs, args):
|
|||||||
utils.print_dict(healthcheck._info)
|
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',
|
@utils.arg('cpulse',
|
||||||
metavar='<cpulse>',
|
metavar='<cpulse>',
|
||||||
nargs='+',
|
nargs='+',
|
||||||
|
2
tox.ini
2
tox.ini
@ -5,7 +5,7 @@ skipsdist = True
|
|||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
install_command = pip install -U {opts} {packages}
|
install_command = pip install {opts} {packages}
|
||||||
setenv =
|
setenv =
|
||||||
VIRTUAL_ENV={envdir}
|
VIRTUAL_ENV={envdir}
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user