From 746c1eb8b66ef38d3b21db2010cc820cb92c0293 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Fri, 9 Feb 2018 07:01:16 +0100 Subject: Move get_dict_by_test() into run_tests.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It also removes functest_utils.get_criteria_by_test() Change-Id: I3f265642acd053755e32f8e92f1086b93517c247 Signed-off-by: Cédric Ollivier --- functest/ci/run_tests.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'functest/ci/run_tests.py') diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index 89c74a97..9edf1347 100644 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -25,10 +25,10 @@ import pkg_resources import enum import prettytable +import yaml import functest.ci.tier_builder as tb import functest.core.testcase as testcase -import functest.utils.functest_utils as ft_utils from functest.utils.constants import CONST # __name__ cannot be used here @@ -113,11 +113,24 @@ class Runner(object): os.environ[key] = value setattr(CONST, key, value) + @staticmethod + def get_dict_by_test(testname): + # pylint: disable=bad-continuation,missing-docstring + with open(pkg_resources.resource_filename( + 'functest', 'ci/testcases.yaml')) as tyaml: + testcases_yaml = yaml.safe_load(tyaml) + for dic_tier in testcases_yaml.get("tiers"): + for dic_testcase in dic_tier['testcases']: + if dic_testcase['case_name'] == testname: + return dic_testcase + LOGGER.error('Project %s is not defined in testcases.yaml', testname) + return None + @staticmethod def get_run_dict(testname): """Obtain the 'run' block of the testcase from testcases.yaml""" try: - dic_testcase = ft_utils.get_dict_by_test(testname) + dic_testcase = Runner.get_dict_by_test(testname) if not dic_testcase: LOGGER.error("Cannot get %s's config options", testname) elif 'run' in dic_testcase: @@ -139,7 +152,7 @@ class Runner(object): try: module = importlib.import_module(run_dict['module']) cls = getattr(module, run_dict['class']) - test_dict = ft_utils.get_dict_by_test(test.get_name()) + test_dict = Runner.get_dict_by_test(test.get_name()) test_case = cls(**test_dict) self.executed_test_cases[test.get_name()] = test_case try: -- cgit 1.2.3-korg