summaryrefslogtreecommitdiff
path: root/heatclient/tests
diff options
context:
space:
mode:
authorThomas Herve <therve@redhat.com>2017-10-03 16:10:29 +0200
committerThomas Herve <therve@redhat.com>2017-10-05 10:56:10 +0200
commit2a8ce0d0656f47331a164163f9e3b302de4d3c88 (patch)
treef0e76c0572ba1ca7e11feacb2553db641519c55b /heatclient/tests
parentbfa77b57c682005ec4c5fd28e02042d2130ed703 (diff)
downloadpython-heatclient-2a8ce0d0656f47331a164163f9e3b302de4d3c88.tar.gz
Don't override sections in deep_update
When you comment all the elements in a YAML mapping, you end up with None instead of an empty mapping, which can have bad side effect when handling multiple environemnents. Let's handle that by ignoring the latest None value. Change-Id: I77ffabeb8d4cd2886ef4f41351e42ebe487b5d4b
Diffstat (limited to 'heatclient/tests')
-rw-r--r--heatclient/tests/unit/test_template_utils.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/heatclient/tests/unit/test_template_utils.py b/heatclient/tests/unit/test_template_utils.py
index a48e0b3..01cfa13 100644
--- a/heatclient/tests/unit/test_template_utils.py
+++ b/heatclient/tests/unit/test_template_utils.py
@@ -448,6 +448,51 @@ class ShellEnvironmentTest(testtools.TestCase):
])
+ @mock.patch('six.moves.urllib.request.urlopen')
+ def test_process_multiple_environments_empty_registry(self, mock_url):
+ # Setup
+ env_file1 = '/home/my/dir/env1.yaml'
+ env_file2 = '/home/my/dir/env2.yaml'
+
+ env1 = b'''
+ resource_registry:
+ "OS::Thingy1": "file:///home/b/a.yaml"
+ '''
+ env2 = b'''
+ resource_registry:
+ '''
+ mock_url.side_effect = [six.BytesIO(env1),
+ six.BytesIO(self.template_a),
+ six.BytesIO(self.template_a),
+ six.BytesIO(env2)]
+
+ # Test
+ env_file_list = []
+ files, env = template_utils.process_multiple_environments_and_files(
+ [env_file1, env_file2], env_list_tracker=env_file_list)
+
+ # Verify
+ expected_env = {
+ 'resource_registry': {'OS::Thingy1': 'file:///home/b/a.yaml'}}
+ self.assertEqual(expected_env, env)
+
+ self.assertEqual(self.template_a.decode('utf-8'),
+ files['file:///home/b/a.yaml'])
+
+ self.assertEqual(['file:///home/my/dir/env1.yaml',
+ 'file:///home/my/dir/env2.yaml'], env_file_list)
+ self.assertIn('file:///home/my/dir/env1.yaml', files)
+ self.assertIn('file:///home/my/dir/env2.yaml', files)
+ self.assertEqual(expected_env,
+ json.loads(files['file:///home/my/dir/env1.yaml']))
+ mock_url.assert_has_calls([
+ mock.call('file://%s' % env_file1),
+ mock.call('file:///home/b/a.yaml'),
+ mock.call('file:///home/b/a.yaml'),
+ mock.call('file://%s' % env_file2),
+
+ ])
+
def test_global_files(self):
url = 'file:///home/b/a.yaml'
env = '''