From 71d97eb7a875139f21be9503ae4666e0a95fc1e5 Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Thu, 15 Dec 2016 16:52:57 -0500 Subject: [PATCH] Call load_environment before mocking it The load_environment call happened after mocking, resulting in a mock object being used for the duplicated IP test. Inspecting inventory.keys() during this test shows a length of 29, with only the groups defined in the config file being present. Moving the call outside the mocked context and providing data instead moves the number of keys up to 240, which includes the entries from the environment. While this change isn't necessarily material to the check for duplicated IPs, it is closer to the intent of exercising the generation system fully. Change-Id: I1e17e3ca4227f1da3fc7aa8accda4e93fa90d245 --- tests/test_inventory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_inventory.py b/tests/test_inventory.py index a38b3eeefb..c029445cc6 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -449,6 +449,7 @@ class TestIps(unittest.TestCase): def setUp(self): # Allow custom assertion errors. self.longMessage = True + self.env = fs.load_environment(BASE_ENV_DIR, {}) @mock.patch('filesystem.load_environment') @mock.patch('filesystem.load_user_configuration') @@ -457,7 +458,7 @@ class TestIps(unittest.TestCase): # Grab our values read from the file system just once. mock_load_config.return_value = get_config() - mock_load_env.return_value = fs.load_environment(BASE_ENV_DIR, {}) + mock_load_env.return_value = self.env mock_open = mock.mock_open()