diff --git a/test/TestInventory.py b/test/TestInventory.py index e46027a5e6..3a1cae1e4f 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -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 diff --git a/test/complex_hosts b/test/complex_hosts index 5153bf095d..0b5ce8c19c 100644 --- a/test/complex_hosts +++ b/test/complex_hosts @@ -85,3 +85,5 @@ host[1:2] [role2] host[2:3] +[role3] +host[1:3:2] diff --git a/test/inventory/test_alpha_end_before_beg b/test/inventory/test_alpha_end_before_beg new file mode 100644 index 0000000000..1b7a478d87 --- /dev/null +++ b/test/inventory/test_alpha_end_before_beg @@ -0,0 +1,2 @@ +[test] +host[Z:T] diff --git a/test/inventory/test_combined_range b/test/inventory/test_combined_range new file mode 100644 index 0000000000..cbcb41753e --- /dev/null +++ b/test/inventory/test_combined_range @@ -0,0 +1,2 @@ +[test] +host[1:2][A:B] diff --git a/test/inventory/test_incorrect_format b/test/inventory/test_incorrect_format new file mode 100644 index 0000000000..339bd59edf --- /dev/null +++ b/test/inventory/test_incorrect_format @@ -0,0 +1,2 @@ +[test] +host[001:10] diff --git a/test/inventory/test_incorrect_range b/test/inventory/test_incorrect_range new file mode 100644 index 0000000000..272ca7be71 --- /dev/null +++ b/test/inventory/test_incorrect_range @@ -0,0 +1,2 @@ +[test] +host[1:2:3:4] diff --git a/test/inventory/test_missing_end b/test/inventory/test_missing_end new file mode 100644 index 0000000000..ff32042402 --- /dev/null +++ b/test/inventory/test_missing_end @@ -0,0 +1,2 @@ +[test] +host[1:]