From cc2cd06eda3939717343c812ff128035c08d4dde Mon Sep 17 00:00:00 2001 From: Qixiang Wan Date: Oct 19 2017 09:07:24 +0000 Subject: Fix test failures caused by pungi conf template move pungi conf template was moved to a seperate file, some tests fail due to that. --- diff --git a/server/tests/test_composerthread.py b/server/tests/test_composerthread.py index da88406..75a843a 100644 --- a/server/tests/test_composerthread.py +++ b/server/tests/test_composerthread.py @@ -24,6 +24,8 @@ import os import time from mock import patch, MagicMock + +import odcs.server from odcs.server import db, app from odcs.server.models import Compose from odcs.common.types import COMPOSE_STATES, COMPOSE_RESULTS, COMPOSE_FLAGS @@ -44,6 +46,16 @@ class TestComposerThread(ModelsBaseTest): super(TestComposerThread, self).setUp() self.composer = ComposerThread() + patched_pungi_conf_path = os.path.join(thisdir, '../conf/pungi.conf') + self.patch_pungi_conf_path = patch.object(odcs.server.conf, + 'pungi_conf_path', + new=patched_pungi_conf_path) + self.patch_pungi_conf_path.start() + + def tearDown(self): + super(TestComposerThread, self).tearDown() + self.patch_pungi_conf_path.stop() + def _wait_for_compose_state(self, id, state): c = None for i in range(20): diff --git a/server/tests/test_pungi.py b/server/tests/test_pungi.py index b462ea1..b6a4c43 100644 --- a/server/tests/test_pungi.py +++ b/server/tests/test_pungi.py @@ -27,6 +27,7 @@ import unittest from mock import patch +import odcs.server from odcs.server.pungi import Pungi, PungiConfig, PungiSourceType test_dir = os.path.abspath(os.path.dirname(__file__)) @@ -35,7 +36,16 @@ test_dir = os.path.abspath(os.path.dirname(__file__)) class TestPungiConfig(unittest.TestCase): def setUp(self): - pass + super(TestPungiConfig, self).setUp() + patched_pungi_conf_path = os.path.join(test_dir, '../conf/pungi.conf') + self.patch_pungi_conf_path = patch.object(odcs.server.conf, + 'pungi_conf_path', + new=patched_pungi_conf_path) + self.patch_pungi_conf_path.start() + + def tearDown(self): + super(TestPungiConfig, self).tearDown() + self.patch_pungi_conf_path.stop() def test_pungi_config_module(self): pungi_cfg = PungiConfig("MBS-512", "1", PungiSourceType.MODULE, @@ -86,7 +96,16 @@ class TestPungiConfig(unittest.TestCase): class TestPungi(unittest.TestCase): def setUp(self): - pass + super(TestPungi, self).setUp() + patched_pungi_conf_path = os.path.join(test_dir, '../conf/pungi.conf') + self.patch_pungi_conf_path = patch.object(odcs.server.conf, + 'pungi_conf_path', + new=patched_pungi_conf_path) + self.patch_pungi_conf_path.start() + + def tearDown(self): + super(TestPungi, self).tearDown() + self.patch_pungi_conf_path.stop() @patch("odcs.server.utils.execute_cmd") def test_pungi_run(self, execute_cmd):