From 61f132a6092951a86fab483ac24854814b78df40 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 6 Jun 2016 02:26:07 -0500 Subject: [PATCH] Adding unit tests for playbook group/host vars --- test/units/vars/test_variable_manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/units/vars/test_variable_manager.py b/test/units/vars/test_variable_manager.py index c808262222..86890eed7f 100644 --- a/test/units/vars/test_variable_manager.py +++ b/test/units/vars/test_variable_manager.py @@ -274,16 +274,26 @@ class TestVariableManager(unittest.TestCase): fake_loader.push("/etc/ansible/host_vars/host1", """ host_var: host_var_from_host_vars_host1 """) + fake_loader.push("group_vars/group1", """ + playbook_group_var: playbook_group_var + """) + fake_loader.push("host_vars/host1", """ + playbook_host_var: playbook_host_var + """) v.add_group_vars_file("/etc/ansible/group_vars/all", loader=fake_loader) v.add_group_vars_file("/etc/ansible/group_vars/group1", loader=fake_loader) v.add_group_vars_file("/etc/ansible/group_vars/group2", loader=fake_loader) + v.add_group_vars_file("group_vars/group1", loader=fake_loader) v.add_host_vars_file("/etc/ansible/host_vars/host1", loader=fake_loader) + v.add_host_vars_file("host_vars/host1", loader=fake_loader) res = v.get_vars(loader=fake_loader, play=play1, host=h1) self.assertEqual(res['group_var'], 'group_var_from_group_vars_group1') self.assertEqual(res['group_var_all'], 'group_var_all_from_group_vars_all') + self.assertEqual(res['playbook_group_var'], 'playbook_group_var') self.assertEqual(res['host_var'], 'host_var_from_host_vars_host1') + self.assertEqual(res['playbook_host_var'], 'playbook_host_var') # add in the fact cache v._fact_cache['host1'] = dict(fact_cache_var="fact_cache_var_from_fact_cache")