From 96bacd7d8ffb9c05672c0a1fc6e68d19e4a6793a Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Sat, 8 Apr 2017 13:38:45 +0200 Subject: Modify TestCase constructor attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every feature/testcase now allows receiving the data defined in testcases.yaml as args (name is renamed to case_name). From the time being, only project and case names are handled. Next pending patches will add criteria, cmd and repo to this list. It keeps the default values for case names except for features which will be aggregated into Feature. Change-Id: Id742d100b8183d7f10894c24ae6879d1b2b60ac9 Signed-off-by: Cédric Ollivier --- functest/core/feature.py | 10 +++++----- functest/core/pytest_suite_runner.py | 4 ++-- functest/core/testcase.py | 6 +++--- functest/core/vnf_base.py | 9 ++++----- 4 files changed, 14 insertions(+), 15 deletions(-) (limited to 'functest/core') diff --git a/functest/core/feature.py b/functest/core/feature.py index 5149f80f..9f20a426 100644 --- a/functest/core/feature.py +++ b/functest/core/feature.py @@ -8,13 +8,13 @@ from functest.utils.constants import CONST class Feature(base.TestCase): - def __init__(self, project='functest', case_name='', repo='', cmd=''): - super(Feature, self).__init__(case_name=case_name) - self.project_name = project - self.cmd = cmd + def __init__(self, **kwargs): + super(Feature, self).__init__(**kwargs) + self.cmd = kwargs.get('cmd', '') + repo = kwargs.get('repo', '') self.repo = CONST.__getattribute__(repo) self.result_file = self.get_result_file() - self.logger = ft_logger.Logger(project).getLogger() + self.logger = ft_logger.Logger(self.project_name).getLogger() def run(self, **kwargs): self.prepare() diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py index 9cfaea7a..775f0a66 100644 --- a/functest/core/pytest_suite_runner.py +++ b/functest/core/pytest_suite_runner.py @@ -15,8 +15,8 @@ class PyTestSuiteRunner(base.TestCase): This superclass is designed to execute pre-configured unittest.TestSuite() objects """ - def __init__(self, case_name=''): - super(PyTestSuiteRunner, self).__init__(case_name) + def __init__(self, **kwargs): + super(PyTestSuiteRunner, self).__init__(**kwargs) self.suite = None def run(self, **kwargs): diff --git a/functest/core/testcase.py b/functest/core/testcase.py index 8c5fd647..3b43aefb 100644 --- a/functest/core/testcase.py +++ b/functest/core/testcase.py @@ -27,10 +27,10 @@ class TestCase(object): logger = ft_logger.Logger(__name__).getLogger() - def __init__(self, case_name=""): + def __init__(self, **kwargs): self.details = {} - self.project_name = "functest" - self.case_name = case_name + self.project_name = kwargs.get('project_name', 'functest') + self.case_name = kwargs.get('case_name', '') self.criteria = "" self.start_time = "" self.stop_time = "" diff --git a/functest/core/vnf_base.py b/functest/core/vnf_base.py index 3d3a441f..3c71ec77 100644 --- a/functest/core/vnf_base.py +++ b/functest/core/vnf_base.py @@ -21,11 +21,10 @@ class VnfOnBoardingBase(base.TestCase): logger = ft_logger.Logger(__name__).getLogger() - def __init__(self, project='functest', case_name='', repo='', cmd=''): - super(VnfOnBoardingBase, self).__init__(case_name=case_name) - self.repo = repo - self.project_name = project - self.cmd = cmd + def __init__(self, **kwargs): + super(VnfOnBoardingBase, self).__init__(**kwargs) + self.repo = kwargs.get('repo', '') + self.cmd = kwargs.get('cmd', '') self.details = {} self.result_dir = CONST.dir_results self.details['orchestrator'] = {} -- cgit 1.2.3-korg