aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting/tests
diff options
context:
space:
mode:
authorVincent Danno <vincent.danno@orange.com>2021-05-10 11:27:15 +0200
committerVincent Danno <vincent.danno@orange.com>2021-05-10 15:39:17 +0200
commiteddde23de6b133486c6d23a19f9197025a00c459 (patch)
treed10031e6330beb2f78b380e079faa3dd5fada27b /xtesting/tests
parent81576fd969217d38f2ccc26434ea286bb704df94 (diff)
Use constants instead of hard-coding paths
Signed-off-by: Vincent Danno <vincent.danno@orange.com> Change-Id: I9bef7db7584d6b615ef102d13797914095512733
Diffstat (limited to 'xtesting/tests')
-rw-r--r--xtesting/tests/unit/core/test_feature.py5
-rw-r--r--xtesting/tests/unit/core/test_testcase.py25
2 files changed, 19 insertions, 11 deletions
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)