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

This commit is contained in:
James Cammarata 2013-08-23 08:52:02 -05:00
commit 4dc209f731
7 changed files with 35 additions and 2 deletions

View file

@ -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

View file

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

View file

@ -0,0 +1,2 @@
[test]
host[Z:T]

View file

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

View file

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

View file

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

View file

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