aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
Diffstat (limited to 'functest')
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py2
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py16
2 files changed, 17 insertions, 1 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 88d96ebd..72ea5ce7 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -130,6 +130,8 @@ def backup_tempest_config(conf_file):
"""
Copy config file to tempest results directory
"""
+ if not os.path.exists(TEMPEST_RESULTS_DIR):
+ os.makedirs(TEMPEST_RESULTS_DIR)
shutil.copyfile(conf_file,
os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf'))
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 77558086..22017a7a 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -170,9 +170,23 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
def test_backup_tempest_config_default(self):
with mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.shutil.copyfile') as m1:
+ 'conf_utils.os.path.exists',
+ return_value=False), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.os.makedirs') as m1, \
+ mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.shutil.copyfile') as m2:
conf_utils.backup_tempest_config('test_conf_file')
self.assertTrue(m1.called)
+ self.assertTrue(m2.called)
+
+ with mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.os.path.exists',
+ return_value=True), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.'
+ 'conf_utils.shutil.copyfile') as m2:
+ conf_utils.backup_tempest_config('test_conf_file')
+ self.assertTrue(m2.called)
def test_configure_tempest_default(self):
with mock.patch('functest.opnfv_tests.openstack.tempest.'