diff options
Diffstat (limited to 'functest/cli/commands')
-rw-r--r-- | functest/cli/commands/cli_env.py | 21 | ||||
-rw-r--r-- | functest/cli/commands/cli_os.py | 15 | ||||
-rw-r--r-- | functest/cli/commands/cli_testcase.py | 53 | ||||
-rw-r--r-- | functest/cli/commands/cli_tier.py | 53 |
4 files changed, 55 insertions, 87 deletions
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py index c41f8f34..c1b66da4 100644 --- a/functest/cli/commands/cli_env.py +++ b/functest/cli/commands/cli_env.py @@ -5,7 +5,8 @@ # 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 -# + +# pylint: disable=missing-docstring import click import prettytable @@ -15,12 +16,10 @@ from functest.utils.constants import CONST import six -class Env(object): +class Env(object): # pylint: disable=too-few-public-methods - def __init__(self): - pass - - def show(self): + @staticmethod + def show(): def _get_value(attr, default='Unknown'): return attr if attr else default @@ -44,13 +43,11 @@ class Env(object): return env_info -class CliEnv(Env): - - def __init__(self): - super(CliEnv, self).__init__() +class CliEnv(object): # pylint: disable=too-few-public-methods - def show(self): - env_info = super(CliEnv, self).show() + @staticmethod + def show(): + env_info = Env.show() msg = prettytable.PrettyTable( header_style='upper', padding_width=5, field_names=['Functest Environment', 'value']) diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py index 9057da84..a543e845 100644 --- a/functest/cli/commands/cli_os.py +++ b/functest/cli/commands/cli_os.py @@ -5,13 +5,13 @@ # 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 -# +# pylint: disable=missing-docstring import os import click -from six.moves.urllib.parse import urlparse +from six.moves import urllib from functest.ci import check_deployment from functest.utils.constants import CONST @@ -25,8 +25,8 @@ class OpenStack(object): self.endpoint_port = None self.openstack_creds = CONST.__getattribute__('openstack_creds') if self.os_auth_url: - self.endpoint_ip = urlparse(self.os_auth_url).hostname - self.endpoint_port = urlparse(self.os_auth_url).port + self.endpoint_ip = urllib.parse.urlparse(self.os_auth_url).hostname + self.endpoint_port = urllib.parse.urlparse(self.os_auth_url).port def ping_endpoint(self): if self.os_auth_url is None: @@ -55,12 +55,9 @@ class OpenStack(object): class CliOpenStack(OpenStack): - def __init__(self): - super(CliOpenStack, self).__init__() - @staticmethod def show_credentials(): dic_credentials = OpenStack.show_credentials() for key, value in dic_credentials.items(): - if key.startswith('OS_'): - click.echo("{}={}".format(key, value)) + if key.startswith('OS_'): + click.echo("{}={}".format(key, value)) diff --git a/functest/cli/commands/cli_testcase.py b/functest/cli/commands/cli_testcase.py index ee7afa5a..a8ead5f5 100644 --- a/functest/cli/commands/cli_testcase.py +++ b/functest/cli/commands/cli_testcase.py @@ -5,27 +5,16 @@ # 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 pkg_resources +# pylint: disable=missing-docstring import click -import functest.ci.tier_builder as tb -from functest.utils.constants import CONST -import functest.utils.functest_utils as ft_utils -import functest.utils.functest_vacation as vacation +from functest.cli.commands import cli_tier +from functest.utils import functest_utils -class Testcase(object): - - def __init__(self): - self.tiers = tb.TierBuilder( - CONST.__getattribute__('INSTALLER_TYPE'), - CONST.__getattribute__('DEPLOY_SCENARIO'), - pkg_resources.resource_filename('functest', 'ci/testcases.yaml')) +class Testcase(cli_tier.Tier): def list(self): summary = "" @@ -34,40 +23,28 @@ class Testcase(object): summary += (" %s\n" % test.get_name()) return summary - def show(self, testname): - description = self.tiers.get_test(testname) + def show(self, name): + description = self.tiers.get_test(name) return description @staticmethod - def run(testname, noclean=False, report=False): - - flags = "" - if noclean: - flags += "-n " - if report: - flags += "-r " - - if testname == 'vacation': - vacation.main() - else: - tests = testname.split(",") - for test in tests: - cmd = "run_tests {}-t {}".format(flags, test) - ft_utils.execute_command(cmd) + def run(name, noclean=False, report=False): + tests = name.split(",") + for test in tests: + cmd = "run_tests {}-t {}".format( + Testcase.get_flags(noclean, report), test) + functest_utils.execute_command(cmd) class CliTestcase(Testcase): - def __init__(self): - super(CliTestcase, self).__init__() - def list(self): click.echo(super(CliTestcase, self).list()) - def show(self, testname): - testcase_show = super(CliTestcase, self).show(testname) + def show(self, name): + testcase_show = super(CliTestcase, self).show(name) if testcase_show: click.echo(testcase_show) else: click.echo("The test case '%s' does not exist or is not supported." - % testname) + % name) diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py index 104cf10b..7aa3f714 100644 --- a/functest/cli/commands/cli_tier.py +++ b/functest/cli/commands/cli_tier.py @@ -5,23 +5,22 @@ # 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 """ +# pylint: disable=missing-docstring import pkg_resources import click -import functest.ci.tier_builder as tb +from functest.ci import tier_builder from functest.utils.constants import CONST -import functest.utils.functest_utils as ft_utils +from functest.utils import functest_utils class Tier(object): def __init__(self): - self.tiers = tb.TierBuilder( + self.tiers = tier_builder.TierBuilder( CONST.__getattribute__('INSTALLER_TYPE'), CONST.__getattribute__('DEPLOY_SCENARIO'), pkg_resources.resource_filename('functest', 'ci/testcases.yaml')) @@ -35,56 +34,54 @@ class Tier(object): tier.get_test_names())) return summary - def show(self, tiername): - tier = self.tiers.get_tier(tiername) + def show(self, name): + tier = self.tiers.get_tier(name) if tier is None: return None - else: - tier_info = self.tiers.get_tier(tiername) - return tier_info + tier_info = self.tiers.get_tier(name) + return tier_info - def gettests(self, tiername): - tier = self.tiers.get_tier(tiername) + def gettests(self, name): + tier = self.tiers.get_tier(name) if tier is None: return None - else: - tests = tier.get_test_names() - return tests + tests = tier.get_test_names() + return tests @staticmethod - def run(tiername, noclean=False, report=False): + def get_flags(noclean=False, report=False): flags = "" if noclean: flags += "-n " if report: flags += "-r " + return flags - cmd = "run_tests {}-t {}".format(flags, tiername) - ft_utils.execute_command(cmd) + @staticmethod + def run(name, noclean=False, report=False): + cmd = "run_tests {}-t {}".format(Tier.get_flags(noclean, report), name) + functest_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) + def show(self, name): + tier_info = super(CliTier, self).show(name) 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)) + "Available tiers are:\n %s\n" % (name, tier_names)) - def gettests(self, tiername): - tests = super(CliTier, self).gettests(tiername) + def gettests(self, name): + tests = super(CliTier, self).gettests(name) if tests: - click.echo("Test cases in tier '%s':\n %s\n" % (tiername, tests)) + click.echo("Test cases in tier '%s':\n %s\n" % (name, 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)) + "Available tiers are:\n %s\n" % (name, tier_names)) |