summaryrefslogtreecommitdiff
path: root/test/TestInventory.py
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2012-05-06 18:01:11 -0400
committerMichael DeHaan <michael.dehaan@gmail.com>2012-05-06 18:01:11 -0400
commit157d21b1c33064ec5987d437120755859b30cded (patch)
treeaa39597b4643d6460ac46e4d0ac57788bfa8f8d4 /test/TestInventory.py
parent1a00e2635e67ee82411714c52f24f89fdfe0d353 (diff)
downloadansible-157d21b1c33064ec5987d437120755859b30cded.tar.gz
Add tests for new advanced inventory features (groups of groups, group variables) in the default INI format file.
Diffstat (limited to 'test/TestInventory.py')
-rw-r--r--test/TestInventory.py42
1 files changed, 34 insertions, 8 deletions
diff --git a/test/TestInventory.py b/test/TestInventory.py
index 58650cecd1..2a8930277c 100644
--- a/test/TestInventory.py
+++ b/test/TestInventory.py
@@ -11,9 +11,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.inventory_script = os.path.join(self.test_dir, 'inventory_api.py')
- self.inventory_yaml = os.path.join(self.test_dir, 'yaml_hosts')
+ 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_yaml = os.path.join(self.test_dir, 'yaml_hosts')
os.chmod(self.inventory_script, 0755)
@@ -28,16 +29,20 @@ class TestInventory(unittest.TestCase):
assert left == right
- ### Simple inventory format tests
-
def simple_inventory(self):
- return Inventory( self.inventory_file )
+ return Inventory(self.inventory_file)
def script_inventory(self):
- return Inventory( self.inventory_script )
+ return Inventory(self.inventory_script)
def yaml_inventory(self):
- return Inventory( self.inventory_yaml )
+ return Inventory(self.inventory_yaml)
+
+ def complex_inventory(self):
+ return Inventory(self.complex_inventory_file)
+
+ #####################################
+ ### Simple inventory format tests
def test_simple(self):
inventory = self.simple_inventory()
@@ -113,6 +118,27 @@ class TestInventory(unittest.TestCase):
print expected
assert vars == expected
+ ###################################################
+ ### INI file advanced tests
+
+ def test_complex_vars(self):
+ inventory = self.complex_inventory()
+
+ vars = inventory.get_variables('rtp_a')
+ print vars
+
+ expected = dict(
+ a='1', b='2', c='3', d='100002',
+ inventory_hostname='rtp_a',
+ group_names=[ 'eastcoast', 'nc', 'rtp', 'us' ]
+ )
+ print vars
+ print expected
+ assert vars == expected
+
+
+
+ ###################################################
### Inventory API tests
def test_script(self):