diff options
author | Norman J. Harman Jr <njharman@gmail.com> | 2012-12-11 03:48:38 +0100 |
---|---|---|
committer | Norman J. Harman Jr <njharman@gmail.com> | 2012-12-11 03:48:38 +0100 |
commit | 6603737e4d52f09c83c75cbf34385cd033e9076f (patch) | |
tree | b0ce96201f6d3e456b6f9eea9416c8952d2a7501 /test | |
parent | Merge pull request #1718 from jpmens/andoc2 (diff) | |
download | ansible-6603737e4d52f09c83c75cbf34385cd033e9076f.tar.xz ansible-6603737e4d52f09c83c75cbf34385cd033e9076f.zip |
Alphabetic inventory hostname patterns.
- Code, docs, tests.
- Also added test of large range 000-142 to verify alpha range did not
break this.
Diffstat (limited to 'test')
-rw-r--r-- | test/TestInventory.py | 44 | ||||
-rw-r--r-- | test/large_range | 1 | ||||
-rw-r--r-- | test/simple_hosts | 4 |
3 files changed, 29 insertions, 20 deletions
diff --git a/test/TestInventory.py b/test/TestInventory.py index 5c444d9e96..06dffd1fd7 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -9,9 +9,10 @@ class TestInventory(unittest.TestCase): self.cwd = os.getcwd() self.test_dir = os.path.join(self.cwd, 'test') - self.inventory_file = os.path.join(self.test_dir, 'simple_hosts') - self.complex_inventory_file = os.path.join(self.test_dir, 'complex_hosts') - self.inventory_script = os.path.join(self.test_dir, 'inventory_api.py') + self.inventory_file = os.path.join(self.test_dir, 'simple_hosts') + self.large_range_inventory_file = os.path.join(self.test_dir, 'large_range') + self.complex_inventory_file = os.path.join(self.test_dir, 'complex_hosts') + self.inventory_script = os.path.join(self.test_dir, 'inventory_api.py') os.chmod(self.inventory_script, 0755) @@ -29,38 +30,36 @@ class TestInventory(unittest.TestCase): def simple_inventory(self): return Inventory(self.inventory_file) + def large_range_inventory(self): + return Inventory(self.large_range_inventory_file) + def script_inventory(self): return Inventory(self.inventory_script) def complex_inventory(self): return Inventory(self.complex_inventory_file) + all_simple_hosts=['jupiter', 'saturn', 'zeus', 'hera', + 'cerberus001','cerberus002','cerberus003', + 'cottus99', 'cottus100', + 'poseidon', 'thor', 'odin', 'loki', + 'thrudgelmir0', 'thrudgelmir1', 'thrudgelmir2', + 'thrudgelmir3', 'thrudgelmir4', 'thrudgelmir5', + 'Hotep-a', 'Hotep-b', 'Hotep-c', + 'BastC', 'BastD', ] + ##################################### ### Simple inventory format tests def test_simple(self): inventory = self.simple_inventory() hosts = inventory.list_hosts() - - expected_hosts=['jupiter', 'saturn', 'zeus', 'hera', - 'cerberus001','cerberus002','cerberus003', - 'cottus99', 'cottus100', - 'poseidon', 'thor', 'odin', 'loki', - 'thrudgelmir0', 'thrudgelmir1', 'thrudgelmir2', - 'thrudgelmir3', 'thrudgelmir4', 'thrudgelmir5'] - assert sorted(hosts) == sorted(expected_hosts) + self.assertEqual(sorted(hosts), sorted(self.all_simple_hosts)) def test_simple_all(self): inventory = self.simple_inventory() hosts = inventory.list_hosts('all') - - expected_hosts=['jupiter', 'saturn', 'zeus', 'hera', - 'cerberus001','cerberus002','cerberus003', - 'cottus99', 'cottus100', - 'poseidon', 'thor', 'odin', 'loki', - 'thrudgelmir0', 'thrudgelmir1', 'thrudgelmir2', - 'thrudgelmir3', 'thrudgelmir4', 'thrudgelmir5'] - assert sorted(hosts) == sorted(expected_hosts) + self.assertEqual(sorted(hosts), sorted(self.all_simple_hosts)) def test_simple_norse(self): inventory = self.simple_inventory() @@ -132,6 +131,11 @@ class TestInventory(unittest.TestCase): print expected assert vars == expected + def test_large_range(self): + inventory = self.large_range_inventory() + hosts = inventory.list_hosts() + self.assertEqual(sorted(hosts), sorted('bob%03i' %i for i in range(0, 143))) + ################################################### ### INI file advanced tests @@ -252,7 +256,7 @@ class TestInventory(unittest.TestCase): vars = inventory.get_variables('zeus') print "VARS=%s" % vars - + assert vars == {'inventory_hostname': 'zeus', 'inventory_hostname_short': 'zeus', 'group_names': ['greek', 'major-god']} diff --git a/test/large_range b/test/large_range new file mode 100644 index 0000000000..18cfc22078 --- /dev/null +++ b/test/large_range @@ -0,0 +1 @@ +bob[000:142] diff --git a/test/simple_hosts b/test/simple_hosts index c774afd4b4..669d92a32a 100644 --- a/test/simple_hosts +++ b/test/simple_hosts @@ -13,3 +13,7 @@ cottus[99:100] thor odin loki + +[egyptian] +Hotep-[a:c] +Bast[C:D] |