Merge "Update the details of tempest results"
[functest.git] / functest / cli / commands / cli_testcase.py
1 #!/usr/bin/env python
2 #
3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8
9 # pylint: disable=missing-docstring
10
11 import click
12
13 from functest.cli.commands import cli_tier
14 from functest.utils import functest_utils
15
16
17 class Testcase(cli_tier.Tier):
18
19     def list(self):
20         summary = ""
21         for tier in self.tiers.get_tiers():
22             for test in tier.get_tests():
23                 summary += (" %s\n" % test.get_name())
24         return summary
25
26     def show(self, name):
27         description = self.tiers.get_test(name)
28         return description
29
30     @staticmethod
31     def run(name, noclean=False, report=False):
32         tests = name.split(",")
33         for test in tests:
34             cmd = "run_tests {}-t {}".format(
35                 Testcase.get_flags(noclean, report), test)
36             functest_utils.execute_command(cmd)
37
38
39 class CliTestcase(Testcase):
40
41     def list(self):
42         click.echo(super(CliTestcase, self).list())
43
44     def show(self, name):
45         testcase_show = super(CliTestcase, self).show(name)
46         if testcase_show:
47             click.echo(testcase_show)
48         else:
49             click.echo("The test case '%s' does not exist or is not supported."
50                        % name)