diff --git a/test/TestInventory.py b/test/TestInventory.py index ef551e5816a..bc1cbde0311 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -221,15 +221,14 @@ class TestInventory(unittest.TestCase): def test_yaml(self): inventory = self.yaml_inventory() hosts = inventory.list_hosts() - print hosts - expected_hosts=['jupiter', 'saturn', 'mars', 'zeus', 'hera', 'poseidon', 'thor', 'odin', 'loki'] + expected_hosts=['garfield', 'goofy', 'hera', 'jerry', 'jupiter', 'loki', 'mars', 'mickey', 'odie', 'odin', 'poseidon', 'saturn', 'thor', 'tom', 'zeus'] self.compare(hosts, expected_hosts) def test_yaml_all(self): inventory = self.yaml_inventory() hosts = inventory.list_hosts('all') - expected_hosts=['jupiter', 'saturn', 'mars', 'zeus', 'hera', 'poseidon', 'thor', 'odin', 'loki'] + expected_hosts=['garfield', 'goofy', 'hera', 'jerry', 'jupiter', 'loki', 'mars', 'mickey', 'odie', 'odin', 'poseidon', 'saturn', 'thor', 'tom', 'zeus'] self.compare(hosts, expected_hosts) def test_yaml_norse(self): @@ -323,3 +322,29 @@ class TestInventory(unittest.TestCase): assert 'group_names' in vars assert sorted(vars['group_names']) == [ 'norse', 'ruler' ] + def test_yaml_some_animals(self): + inventory = self.yaml_inventory() + hosts = inventory.list_hosts("cat:mouse") + expected_hosts=['garfield', 'jerry', 'mickey', 'tom'] + self.compare(hosts, expected_hosts) + + def test_yaml_comic(self): + inventory = self.yaml_inventory() + hosts = inventory.list_hosts("comic") + expected_hosts=['garfield', 'odie'] + self.compare(hosts, expected_hosts) + + def test_yaml_orange(self): + inventory = self.yaml_inventory() + hosts = inventory.list_hosts("orange") + expected_hosts=['garfield', 'goofy'] + self.compare(hosts, expected_hosts) + + def test_yaml_garfield_vars(self): + inventory = self.yaml_inventory() + vars = inventory.get_variables('garfield') + assert vars == {'ears': 'pointy', + 'inventory_hostname': 'garfield', + 'group_names': ['cat', 'comic', 'orange'], + 'nose': 'pink'} + diff --git a/test/yaml_hosts b/test/yaml_hosts index ea8b5681de6..8c5130f8cac 100644 --- a/test/yaml_hosts +++ b/test/yaml_hosts @@ -2,7 +2,6 @@ - jupiter - host: saturn - groups: [ multiple ] vars: moon: titan moon2: enceladus @@ -10,12 +9,12 @@ - host: mars - host: zeus - groups: [ greek, ruler ] vars: - ansible_ssh_port: 3001 - group: greek hosts: + - zeus - hera - poseidon vars: @@ -32,4 +31,41 @@ - group: ruler hosts: + - zeus - odin + +- group: multiple + hosts: + - saturn + +- host: garfield + groups: [ comic, cat, orange ] + vars: + - nose: pink + +- host: odie + groups: [ comic, dog, yellow ] + +- host: mickey + groups: [ cartoon, mouse, red ] + +- host: goofy + groups: [ cartoon, dog, orange ] + +- host: tom + groups: [ cartoon, cat, gray ] + +- host: jerry + groups: [ cartoon, mouse, brown ] + +- group: cat + vars: + - ears: pointy + +- group: dog + vars: + - ears: flappy + +- group: mouse + vars: + - ears: round