diff options
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | test-requirements.txt | 4 | ||||
-rw-r--r-- | upper-constraints.txt | 2 | ||||
-rw-r--r-- | xtesting/ci/run_tests.py | 8 | ||||
-rw-r--r-- | xtesting/core/campaign.py | 5 | ||||
-rw-r--r-- | xtesting/tests/unit/core/test_feature.py | 5 | ||||
-rw-r--r-- | xtesting/tests/unit/core/test_testcase.py | 25 | ||||
-rw-r--r-- | xtesting/utils/constants.py | 9 |
8 files changed, 39 insertions, 21 deletions
diff --git a/requirements.txt b/requirements.txt index 3b157e95..7e4804d1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,4 @@ os-testr # Apache-2.0 junitxml boto3 # Apache-2.0 lxml!=3.7.0 # BSD -ansible-runner!=1.3.5 # Apache 2.0 +ansible-runner!=1.3.5 # Apache 2.0 diff --git a/test-requirements.txt b/test-requirements.txt index 28f97df4..69f8008b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,7 @@ coverage!=4.4 # Apache-2.0 mock!=4.0.0,!=4.0.1 # BSD nose # LGPL -flake8<2.6.0,>=2.5.4 # MIT +flake8 # MIT pylint # GPLv2 sphinx!=1.6.6,!=1.6.7,!=2.1.0,!=3.0.0 # BSD sphinx-rtd-theme @@ -13,4 +13,4 @@ doc8 # Apache-2.0 bashate # Apache-2.0 ansible-lint bandit -munch # MIT +munch # MIT diff --git a/upper-constraints.txt b/upper-constraints.txt index 6aca7c83..ee04cbc5 100644 --- a/upper-constraints.txt +++ b/upper-constraints.txt @@ -4,6 +4,6 @@ behave===1.2.6 behave-html-formatter===0.9.4;python_version>='3.5' pylint===1.9.5;python_version=='2.7' pylint===2.4.4;python_version=='3.8' -flake8===3.7.9 +flake8===3.9.2 nose===1.3.7 ansible-lint===4.3.7 diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py index ea606bd4..989969bc 100644 --- a/xtesting/ci/run_tests.py +++ b/xtesting/ci/run_tests.py @@ -308,17 +308,17 @@ class Runner(): def main(): """Entry point""" try: - os.makedirs('/var/lib/xtesting/results/') + os.makedirs(constants.RESULTS_DIR) except OSError as ex: if ex.errno != errno.EEXIST: - six.print_("Cannot create /var/lib/xtesting/results/") + six.print_("{} {}".format("Cannot create", constants.RESULTS_DIR)) return testcase.TestCase.EX_RUN_ERROR if env.get('DEBUG').lower() == 'true': logging.config.fileConfig(pkg_resources.resource_filename( - 'xtesting', 'ci/logging.debug.ini')) + 'xtesting', constants.DEBUG_INI_PATH)) else: logging.config.fileConfig(pkg_resources.resource_filename( - 'xtesting', 'ci/logging.ini')) + 'xtesting', constants.INI_PATH)) logging.captureWarnings(True) parser = RunTestsParser() args = parser.parse_args(sys.argv[1:]) diff --git a/xtesting/core/campaign.py b/xtesting/core/campaign.py index 7c766e53..51a145c1 100644 --- a/xtesting/core/campaign.py +++ b/xtesting/core/campaign.py @@ -26,6 +26,7 @@ from six.moves import urllib from xtesting.core import testcase from xtesting.utils import env +from xtesting.utils import constants __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>" @@ -216,9 +217,9 @@ def main(): os.makedirs(testcase.TestCase.dir_results) if env.get('DEBUG').lower() == 'true': logging.config.fileConfig(pkg_resources.resource_filename( - 'xtesting', 'ci/logging.debug.ini')) + 'xtesting', constants.DEBUG_INI_PATH)) else: logging.config.fileConfig(pkg_resources.resource_filename( - 'xtesting', 'ci/logging.ini')) + 'xtesting', constants.INI_PATH)) logging.captureWarnings(True) Campaign.zip_campaign_files() diff --git a/xtesting/tests/unit/core/test_feature.py b/xtesting/tests/unit/core/test_feature.py index 785f6e16..ab483b27 100644 --- a/xtesting/tests/unit/core/test_feature.py +++ b/xtesting/tests/unit/core/test_feature.py @@ -9,6 +9,8 @@ # pylint: disable=missing-docstring +import os + import logging import subprocess import unittest @@ -18,6 +20,7 @@ import six from xtesting.core import feature from xtesting.core import testcase +from xtesting.utils import constants class FakeTestCase(feature.Feature): @@ -40,7 +43,7 @@ class FeatureTestingBase(unittest.TestCase): _project_name = "bar" _repo = "dir_repo_bar" _cmd = "run_bar_tests.py" - _output_file = '/var/lib/xtesting/results/foo/foo.log' + _output_file = os.path.join(constants.RESULTS_DIR, 'foo/foo.log') feature = None @mock.patch('time.time', side_effect=[1, 2]) diff --git a/xtesting/tests/unit/core/test_testcase.py b/xtesting/tests/unit/core/test_testcase.py index 63bfc3fe..990883c6 100644 --- a/xtesting/tests/unit/core/test_testcase.py +++ b/xtesting/tests/unit/core/test_testcase.py @@ -22,6 +22,7 @@ import mock import requests from xtesting.core import testcase +from xtesting.utils import constants __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>" @@ -400,19 +401,21 @@ class TestCaseTesting(unittest.TestCase): mock.call().meta.client.head_bucket(Bucket='xtesting'), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( - '/var/lib/xtesting/results/xtesting.log', - 'prefix/xtesting.log', + constants.LOG_PATH, + os.path.join('prefix', os.path.basename(constants.LOG_PATH)), Config=mock.ANY, ExtraArgs={'ContentType': 'application/octet-stream'}), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( - '/var/lib/xtesting/results/xtesting.debug.log', - 'prefix/xtesting.debug.log', + constants.DEBUG_LOG_PATH, + os.path.join('prefix', + os.path.basename(constants.DEBUG_LOG_PATH)), Config=mock.ANY, ExtraArgs={'ContentType': 'application/octet-stream'}), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( - '/var/lib/xtesting/results/bar', 'prefix/bar', + os.path.join(constants.RESULTS_DIR, 'bar'), + 'prefix/bar', Config=mock.ANY, ExtraArgs={'ContentType': 'application/octet-stream'})] self.assertEqual(args[1].mock_calls, expected) @@ -432,19 +435,21 @@ class TestCaseTesting(unittest.TestCase): mock.call().meta.client.head_bucket(Bucket='xtesting'), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( - '/var/lib/xtesting/results/xtesting.log', - 'prefix/xtesting.log', + constants.LOG_PATH, + os.path.join('prefix', os.path.basename(constants.LOG_PATH)), Config=mock.ANY, ExtraArgs={'ContentType': 'text/plain'}), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( - '/var/lib/xtesting/results/xtesting.debug.log', - 'prefix/xtesting.debug.log', + constants.DEBUG_LOG_PATH, + os.path.join('prefix', + os.path.basename(constants.DEBUG_LOG_PATH)), Config=mock.ANY, ExtraArgs={'ContentType': 'text/plain'}), mock.call().Bucket('xtesting'), mock.call().Bucket().upload_file( - '/var/lib/xtesting/results/bar', 'prefix/bar', + os.path.join(constants.RESULTS_DIR, 'bar'), + 'prefix/bar', Config=mock.ANY, ExtraArgs={'ContentType': 'text/plain'})] self.assertEqual(args[1].mock_calls, expected) diff --git a/xtesting/utils/constants.py b/xtesting/utils/constants.py index 18e03f68..7677f2e5 100644 --- a/xtesting/utils/constants.py +++ b/xtesting/utils/constants.py @@ -2,4 +2,13 @@ # pylint: disable=missing-docstring +import os + ENV_FILE = '/var/lib/xtesting/conf/env_file' + +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 = 'ci/logging.ini' +DEBUG_INI_PATH = 'ci/logging.debug.ini' |