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
This commit is contained in:
Alex Schultz 2018-11-14 08:27:40 -07:00
parent 31aef3859e
commit ba9e16639f
1 changed files with 7 additions and 0 deletions

View File

@ -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