aboutsummaryrefslogtreecommitdiffstats
path: root/functest/cli/commands/cli_testcase.py
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-11-08 14:18:12 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2016-11-09 16:55:45 +0100
commit107e61635c2ab1feb5263380ea63e21cf2e6e65b (patch)
tree4966b77605bd34a40f452b1d268868691e84d008 /functest/cli/commands/cli_testcase.py
parente74c9b347f2623eb1a3c477921a84da4c31b364f (diff)
Repo structure modification
- create functest subdirectory - rename unit tests - adapt path in exec and config files JIRA: FUNCTEST-525 Change-Id: Ifd5c6edfb5bda1b09f82848e2269ad5fbeb84d0a Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'functest/cli/commands/cli_testcase.py')
-rw-r--r--functest/cli/commands/cli_testcase.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/functest/cli/commands/cli_testcase.py b/functest/cli/commands/cli_testcase.py
new file mode 100644
index 00000000..510d740b
--- /dev/null
+++ b/functest/cli/commands/cli_testcase.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# jose.lausuch@ericsson.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+""" global variables """
+
+import os
+
+import click
+
+import functest.ci.tier_builder as tb
+import functest.utils.functest_utils as ft_utils
+import functest.utils.functest_vacation as vacation
+
+
+FUNCTEST_CONF_DIR = \
+ ft_utils.get_functest_config('general.directories.dir_functest_conf')
+ENV_FILE = FUNCTEST_CONF_DIR + "/env_active"
+FUNCTEST_REPO = ft_utils.FUNCTEST_REPO
+
+
+class CliTestcase:
+
+ def __init__(self):
+ CI_INSTALLER_TYPE = os.getenv('INSTALLER_TYPE')
+ CI_SCENARIO = os.getenv('DEPLOY_SCENARIO')
+ testcases = ft_utils.get_testcases_file()
+ self.tiers = tb.TierBuilder(CI_INSTALLER_TYPE, CI_SCENARIO, testcases)
+
+ def list(self):
+ summary = ""
+ for tier in self.tiers.get_tiers():
+ for test in tier.get_tests():
+ summary += (" %s\n" % test.get_name())
+ click.echo(summary)
+
+ def show(self, testname):
+ description = self.tiers.get_test(testname)
+ if description is None:
+ click.echo("The test case '%s' does not exist or is not supported."
+ % testname)
+
+ click.echo(description)
+
+ def run(self, testname, noclean=False):
+ if testname == 'vacation':
+ vacation.main()
+ elif not os.path.isfile(ENV_FILE):
+ click.echo("Functest environment is not ready. "
+ "Run first 'functest env prepare'")
+ else:
+ if noclean:
+ cmd = ("python %s/ci/run_tests.py "
+ "-n -t %s" % (FUNCTEST_REPO, testname))
+ else:
+ cmd = ("python %s/ci/run_tests.py "
+ "-t %s" % (FUNCTEST_REPO, testname))
+ ft_utils.execute_command(cmd)