Merge branch 'add_tests_inventory' of https://github.com/mscherer/ansible into mscherer-add_tests_inventory

pull/3929/head
James Cammarata 11 years ago
commit 4dc209f731

@ -219,9 +219,9 @@ class TestInventory(unittest.TestCase):
def test_complex_group_names(self):
inventory = self.complex_inventory()
tests = {
'host1': [ 'role1' ],
'host1': [ 'role1', 'role3' ],
'host2': [ 'role1', 'role2' ],
'host3': [ 'role2' ]
'host3': [ 'role2', 'role3' ]
}
for host, roles in tests.iteritems():
group_names = inventory.get_variables(host)['group_names']
@ -270,6 +270,27 @@ class TestInventory(unittest.TestCase):
hosts = inventory.list_hosts("nc:&triangle:!tri_c")
self.compare(hosts, ['tri_a', 'tri_b'])
@raises(errors.AnsibleError)
def test_invalid_range(self):
Inventory(os.path.join(self.test_dir, 'inventory','test_incorrect_range'))
@raises(errors.AnsibleError)
def test_missing_end(self):
Inventory(os.path.join(self.test_dir, 'inventory','test_missing_end'))
@raises(errors.AnsibleError)
def test_incorrect_format(self):
Inventory(os.path.join(self.test_dir, 'inventory','test_incorrect_format'))
@raises(errors.AnsibleError)
def test_alpha_end_before_beg(self):
Inventory(os.path.join(self.test_dir, 'inventory','test_alpha_end_before_beg'))
def test_combined_range(self):
i = Inventory(os.path.join(self.test_dir, 'inventory','test_combined_range'))
hosts = i.list_hosts('test')
expected_hosts=['host1A','host2A','host1B','host2B']
assert sorted(hosts) == sorted(expected_hosts)
###################################################
### Inventory API tests

@ -85,3 +85,5 @@ host[1:2]
[role2]
host[2:3]
[role3]
host[1:3:2]

@ -0,0 +1,2 @@
[test]
host[1:2][A:B]

@ -0,0 +1,2 @@
[test]
host[001:10]

@ -0,0 +1,2 @@
[test]
host[1:2:3:4]

@ -0,0 +1,2 @@
[test]
host[1:]
Loading…
Cancel
Save