aboutsummaryrefslogtreecommitdiffstats
path: root/functest/cli/commands/cli_tier.py
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-06-29 07:12:29 +0000
committerLinda Wang <wangwulin@huawei.com>2017-08-17 09:24:49 +0000
commitecaecd74a20e4845fb748077b759a5697ba86f1c (patch)
treea26e7f5b5b456a78c29ab135f4862a9ca4b2ae25 /functest/cli/commands/cli_tier.py
parent94d1bddfdd97379e50e4c12f26116441e836d0f6 (diff)
API proposal for functest
1. Propose a basic framework for API 2. And these functions have been realized: 1) Show environment 2) Prepare Environment 3) Show credentials 4) List all testcases 5) Show a testcase 6) List all tiers 7) Show a tier 8) List all testcases within given tier JIRA: FUNCTEST-843 Change-Id: Ib961446708077b56465eda0052f6d38806b62594 Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/cli/commands/cli_tier.py')
-rw-r--r--functest/cli/commands/cli_tier.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py
index 9b2e60ba..995354bb 100644
--- a/functest/cli/commands/cli_tier.py
+++ b/functest/cli/commands/cli_tier.py
@@ -19,7 +19,7 @@ from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
-class CliTier(object):
+class Tier(object):
def __init__(self):
self.tiers = tb.TierBuilder(
@@ -34,26 +34,23 @@ class CliTier(object):
% (tier.get_order(),
tier.get_name(),
tier.get_test_names()))
- click.echo(summary)
+ return summary
def show(self, tiername):
tier = self.tiers.get_tier(tiername)
if tier is None:
- tier_names = self.tiers.get_tier_names()
- click.echo("The tier with name '%s' does not exist. "
- "Available tiers are:\n %s\n" % (tiername, tier_names))
+ return None
else:
- click.echo(self.tiers.get_tier(tiername))
+ tier_info = self.tiers.get_tier(tiername)
+ return tier_info
def gettests(self, tiername):
tier = self.tiers.get_tier(tiername)
if tier is None:
- tier_names = self.tiers.get_tier_names()
- click.echo("The tier with name '%s' does not exist. "
- "Available tiers are:\n %s\n" % (tiername, tier_names))
+ return None
else:
tests = tier.get_test_names()
- click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests))
+ return tests
@staticmethod
def run(tiername, noclean=False, report=False):
@@ -70,3 +67,30 @@ class CliTier(object):
else:
cmd = "run_tests {}-t {}".format(flags, tiername)
ft_utils.execute_command(cmd)
+
+
+class CliTier(Tier):
+
+ def __init__(self):
+ super(CliTier, self).__init__()
+
+ def list(self):
+ click.echo(super(CliTier, self).list())
+
+ def show(self, tiername):
+ tier_info = super(CliTier, self).show(tiername)
+ if tier_info:
+ click.echo(tier_info)
+ else:
+ tier_names = self.tiers.get_tier_names()
+ click.echo("The tier with name '%s' does not exist. "
+ "Available tiers are:\n %s\n" % (tiername, tier_names))
+
+ def gettests(self, tiername):
+ tests = super(CliTier, self).gettests(tiername)
+ if tests:
+ click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests))
+ else:
+ tier_names = self.tiers.get_tier_names()
+ click.echo("The tier with name '%s' does not exist. "
+ "Available tiers are:\n %s\n" % (tiername, tier_names))