diff options
Diffstat (limited to 'xtesting')
-rw-r--r-- | xtesting/ci/run_tests.py | 2 | ||||
-rw-r--r-- | xtesting/core/campaign.py | 3 | ||||
-rw-r--r-- | xtesting/core/testcase.py | 5 | ||||
-rw-r--r-- | xtesting/tests/unit/ci/test_tier_handler.py | 4 | ||||
-rw-r--r-- | xtesting/tests/unit/core/test_testcase.py | 6 | ||||
-rw-r--r-- | xtesting/tests/unit/utils/test_decorators.py | 3 | ||||
-rw-r--r-- | xtesting/utils/constants.py | 21 |
7 files changed, 28 insertions, 16 deletions
diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py index 57562ef4..b8c4a803 100644 --- a/xtesting/ci/run_tests.py +++ b/xtesting/ci/run_tests.py @@ -143,7 +143,7 @@ class Runner(): def run_test(self, test): """Run one test case""" - # pylint: disable=too-many-branches + # pylint: disable=too-many-branches,broad-exception-raised if not test.is_enabled() or test.is_skipped(): msg = prettytable.PrettyTable( header_style='upper', padding_width=5, diff --git a/xtesting/core/campaign.py b/xtesting/core/campaign.py index 901df587..98b2f1a8 100644 --- a/xtesting/core/campaign.py +++ b/xtesting/core/campaign.py @@ -70,7 +70,8 @@ class Campaign(): url = env.get('TEST_DB_URL') req = requests.get( f"{url}?build_tag={env.get('BUILD_TAG')}", - headers=testcase.TestCase.headers) + headers=testcase.TestCase.headers, + timeout=10) req.raise_for_status() output = req.json() Campaign.__logger.debug("data from DB: \n%s", output) diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py index b44ed793..380adc5e 100644 --- a/xtesting/core/testcase.py +++ b/xtesting/core/testcase.py @@ -149,7 +149,7 @@ class TestCase(metaclass=abc.ABCMeta): self.__logger.error("Please run test before checking the results") return TestCase.EX_TESTCASE_FAILED - def check_requirements(self): # pylint: disable=no-self-use + def check_requirements(self): """Check the requirements of the test case. It can be overriden on purpose. @@ -235,7 +235,8 @@ class TestCase(metaclass=abc.ABCMeta): data["version"] = "unknown" req = requests.post( url, data=json.dumps(data, sort_keys=True), - headers=self.headers) + headers=self.headers, + timeout=10) req.raise_for_status() if urlparse(url).scheme != "file": # href must be postprocessed as OPNFV testapi is misconfigured diff --git a/xtesting/tests/unit/ci/test_tier_handler.py b/xtesting/tests/unit/ci/test_tier_handler.py index 668f33cc..95dcfdc6 100644 --- a/xtesting/tests/unit/ci/test_tier_handler.py +++ b/xtesting/tests/unit/ci/test_tier_handler.py @@ -26,8 +26,8 @@ class TierHandlerTesting(unittest.TestCase): self.testcase = tier_handler.TestCase( 'test_name', 'true', False, 'test_criteria', True, description='test_desc', project='project_name') - self.testcase.str = self.testcase.__str__() - self.tier.str = self.tier.__str__() + self.testcase.str = str(self.testcase) + self.tier.str = str(self.tier) def test_add_test(self): self.tier.add_test(self.test) diff --git a/xtesting/tests/unit/core/test_testcase.py b/xtesting/tests/unit/core/test_testcase.py index dbefd974..f7d1b940 100644 --- a/xtesting/tests/unit/core/test_testcase.py +++ b/xtesting/tests/unit/core/test_testcase.py @@ -180,7 +180,8 @@ class TestCaseTesting(unittest.TestCase): args[0].assert_called_once_with( os.environ['TEST_DB_URL'], data=json.dumps(payload, sort_keys=True), - headers=self._headers) + headers=self._headers, + timeout=10) def test_pushdb_daily_job(self): self._test_pushdb_version(version="master") @@ -203,7 +204,8 @@ class TestCaseTesting(unittest.TestCase): mock_function.assert_called_once_with( os.environ['TEST_DB_URL'], data=json.dumps(self._get_data(), sort_keys=True), - headers=self._headers) + headers=self._headers, + timeout=10) def test_check_requirements(self): self.test.check_requirements() diff --git a/xtesting/tests/unit/utils/test_decorators.py b/xtesting/tests/unit/utils/test_decorators.py index ae6ffa4b..f5408868 100644 --- a/xtesting/tests/unit/utils/test_decorators.py +++ b/xtesting/tests/unit/utils/test_decorators.py @@ -94,7 +94,8 @@ class DecoratorsTesting(unittest.TestCase): self.assertEqual(test.push_to_db(), testcase.TestCase.EX_OK) args[0].assert_called_once_with( 'http://127.0.0.1', data=self._get_json(), - headers={'Content-Type': 'application/json'}) + headers={'Content-Type': 'application/json'}, + timeout=10) def test_wrong_shema(self): os.environ['TEST_DB_URL'] = '/dev/null' diff --git a/xtesting/utils/constants.py b/xtesting/utils/constants.py index f5e29e0d..12f1fde3 100644 --- a/xtesting/utils/constants.py +++ b/xtesting/utils/constants.py @@ -12,7 +12,7 @@ import os import sys -import pkg_resources +import importlib.resources ENV_FILE = '/var/lib/xtesting/conf/env_file' @@ -20,14 +20,21 @@ XTESTING_PATHES = [ "~/.xtesting", "/etc/xtesting", os.path.join(sys.prefix + "/etc/xtesting")] TESTCASE_DESCRIPTION = 'testcases.yaml' -TESTCASE_DESCRIPTION_DEFAULT = pkg_resources.resource_filename( - 'xtesting', f'ci/{TESTCASE_DESCRIPTION}') + +with importlib.resources.as_file( + importlib.resources.files('xtesting') / + f'ci/{TESTCASE_DESCRIPTION}') as path: + TESTCASE_DESCRIPTION_DEFAULT = path RESULTS_DIR = '/var/lib/xtesting/results' LOG_PATH = os.path.join(RESULTS_DIR, 'xtesting.log') DEBUG_LOG_PATH = os.path.join(RESULTS_DIR, 'xtesting.debug.log') -INI_PATH_DEFAULT = pkg_resources.resource_filename( - 'xtesting', 'ci/logging.ini') -DEBUG_INI_PATH_DEFAULT = pkg_resources.resource_filename( - 'xtesting', 'ci/logging.debug.ini') +with importlib.resources.as_file( + importlib.resources.files('xtesting') / + 'ci/logging.ini') as path: + INI_PATH_DEFAULT = path +with importlib.resources.as_file( + importlib.resources.files('xtesting') / + 'ci/logging.debug.ini') as path: + DEBUG_INI_PATH_DEFAULT = path |