Skip to content

Commit

Permalink
Adding unit tests for playbook group/host vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jimi-c committed Jun 6, 2016
1 parent 2a984bb commit 61f132a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/units/vars/test_variable_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,26 @@ def test_variable_manager_precedence(self, mock_basedir):
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")
Expand Down

0 comments on commit 61f132a

Please sign in to comment.