From ba9e16639fab485e63909a1036fab22901faa235 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Wed, 14 Nov 2018 08:27:40 -0700 Subject: [PATCH] Mock configuration load in unit tests Previously if you had an undercloud.conf in your home directory, the tests would load it and use values from it as the defaults for the tests if they were not overridden in the tests. This could lead to incorrect failures. This change mocks the config loading out from the install and upgrade actions for the undercloud to prevent this loading. Change-Id: I57a12f0151bc65f26a7e880b0f1f367a7711ead9 Closes-Bug: #1803387 --- tripleoclient/tests/v1/undercloud/test_undercloud.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tripleoclient/tests/v1/undercloud/test_undercloud.py b/tripleoclient/tests/v1/undercloud/test_undercloud.py index b5d5bbf33..f49366db3 100644 --- a/tripleoclient/tests/v1/undercloud/test_undercloud.py +++ b/tripleoclient/tests/v1/undercloud/test_undercloud.py @@ -13,6 +13,7 @@ # under the License. # +import fixtures import json import mock import os @@ -42,6 +43,9 @@ class TestUndercloudInstall(TestPluginV1): self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) self.conf.config(container_images_file='/home/stack/foo.yaml') self.conf.set_default('output_dir', '/home/stack') + # don't actually load config from ~/undercloud.conf + self.mock_config_load = self.useFixture( + fixtures.MockPatch('tripleoclient.utils.load_config')) # Get the command object to test app_args = mock.Mock() app_args.verbose_level = 1 @@ -528,6 +532,9 @@ class TestUndercloudUpgrade(TestPluginV1): self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF)) self.conf.config(container_images_file='/home/stack/foo.yaml') self.conf.set_default('output_dir', '/home/stack') + # don't actually load config from ~/undercloud.conf + self.mock_config_load = self.useFixture( + fixtures.MockPatch('tripleoclient.utils.load_config')) # Get the command object to test app_args = mock.Mock() app_args.verbose_level = 1