diff options
author | 2018-01-23 11:19:41 +0100 | |
---|---|---|
committer | 2018-01-24 15:15:34 +0100 | |
commit | bbfe9b09d2b1ac7bfe286311fef83d36c6125c96 (patch) | |
tree | c11ad97f5672454a3b7e2ba13916034919933e5d /functest/cli/commands/cli_tier.py | |
parent | c653ed78d7721b9933e08015e45dd39379aa4316 (diff) |
Fix pylint warnings/errors in cli
cli_testcase and cli_tier have been refactored to avoid duplicating
code. Then functest/cli and funtest/unit/cli can be added to the list
of modules rated 10/10.
Change-Id: Iec90e806397248a10f39080ec554e3f0a6eda7c1
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/cli/commands/cli_tier.py')
-rw-r--r-- | functest/cli/commands/cli_tier.py | 53 |
1 files changed, 25 insertions, 28 deletions
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)) |