summaryrefslogtreecommitdiffstats
path: root/dovetail/cli/commands/cli_testcase.py
diff options
context:
space:
mode:
Diffstat (limited to 'dovetail/cli/commands/cli_testcase.py')
-rw-r--r--dovetail/cli/commands/cli_testcase.py74
1 files changed, 37 insertions, 37 deletions
diff --git a/dovetail/cli/commands/cli_testcase.py b/dovetail/cli/commands/cli_testcase.py
index 7529765f..6711381c 100644
--- a/dovetail/cli/commands/cli_testcase.py
+++ b/dovetail/cli/commands/cli_testcase.py
@@ -19,51 +19,50 @@ import dovetail.utils.dovetail_utils as dt_utils
class CliTestcase(object):
- @classmethod
- def testsuite_load(cls):
+ @staticmethod
+ def testsuite_load():
dt_cfg.load_config_files(constants.CONF_PATH)
Testsuite.load()
- def list_testcase(self, testsuite):
+ @staticmethod
+ def list_one_testsuite(testsuite):
+ testsuite_stream = Testsuite.get(testsuite)
+ if testsuite_stream:
+ mandatory = dt_utils.get_value_from_dict(
+ 'testcases_list.mandatory', testsuite_stream)
+ optional = dt_utils.get_value_from_dict(
+ 'testcases_list.optional', testsuite_stream)
+ if mandatory:
+ click.echo("- mandatory")
+ for testcase in mandatory:
+ click.echo(" {}".format(testcase))
+ if optional:
+ click.echo("- optional")
+ for testcase in optional:
+ click.echo(" {}".format(testcase))
+ if not (mandatory or optional):
+ click.echo("No testcase in testsuite {}".format(testsuite))
+ else:
+ click.echo("testsuite {} does not exist".format(testsuite))
+
+ def list_testsuites(self, testsuite):
self.testsuite_load()
if testsuite:
- testsuite_stream = Testsuite.get(testsuite)
- if testsuite_stream:
- testcase_list = []
- for value in testsuite_stream['testcases_list']:
- if value is not None:
- testcase_list.append(value)
- testarea_list = []
- for testcase in testcase_list:
- testarea = testcase.split('.')[1]
- if testarea not in testarea_list:
- testarea_list.append(testarea)
- for testarea in testarea_list:
- click.echo("- %s" % testarea)
- for testcase in testcase_list:
- if testarea in testcase:
- click.echo(" %s" % testcase)
- else:
- click.echo("testsuite %s does not exist or not supported"
- % testsuite)
+ self.list_one_testsuite(testsuite)
else:
testsuite_json = Testsuite.get_all()
if testsuite_json:
- for key, value in testsuite_json.items():
- click.echo("- %s" % key)
- testsuite_stream = Testsuite.get(key)
- if testsuite_stream['testcases_list']:
- for testcase in testsuite_stream['testcases_list']:
- click.echo(" %s" % testcase)
- else:
- click.echo("No testcase in testsuite %s" % key)
+ for key in testsuite_json.keys():
+ click.echo("--------------------------")
+ click.echo("Test Suite {}".format(key))
+ click.echo("--------------------------")
+ self.list_one_testsuite(key)
else:
click.echo("No testsuite defined yet in dovetail!!!")
- def show_testcase(self, name):
- tc_path = os.path.join(
- constants.TESTCASE_PATH,
- "%s.yml" % (name[9:] if name.startswith('dovetail.') else name))
+ @staticmethod
+ def show_testcase(name):
+ tc_path = os.path.join(constants.TESTCASE_PATH, "{}.yml".format(name))
if os.path.isfile(tc_path):
with open(tc_path, 'r') as stream:
try:
@@ -73,7 +72,8 @@ class CliTestcase(object):
else:
click.echo("testcase %s not exist or not supported" % name)
- def run(self, args_str):
+ @staticmethod
+ def run(args_str):
options = ''
if args_str:
options = options + args_str
@@ -82,7 +82,7 @@ class CliTestcase(object):
os.path.join(os.path.dirname(__file__),
os.pardir, os.pardir))
- cmd = ("python %s/run.py"
+ cmd = ("python3 %s/run.py"
" %s" % (repo_dir, options))
- dt_utils.exec_cmd(cmd, exit_on_error=False,
+ dt_utils.exec_cmd(cmd, exit_on_error=True,
exec_msg_on=False, info=True)