def test_ansible_inventory_headding_mangling(self): g = inventory.InventoryGroup('[foobar]') self.assertEquals(g.heading, '[foobar]') self.assertEquals(g.name, 'foobar') g = inventory.InventoryGroup('foobar]') self.assertEquals(g.heading, '[foobar]') self.assertEquals(g.name, 'foobar') g = inventory.InventoryGroup('foobar') self.assertEquals(g.heading, '[foobar]') self.assertEquals(g.name, 'foobar')
def test_ansible_inventory_group_items(self): base = 'localhost foo=bar bar=baz' h = inventory.InventoryHost.from_string(base) g = inventory.InventoryGroup('[foobar]', [base]) self.assertEquals(len(g.items), 1) self.assertEquals(g.items[0], h) g2 = inventory.InventoryGroup('[foobar]', [h]) self.assertEquals(len(g2.items), 1) self.assertEquals(g.items[0], g2.items[0])
def test_ansible_inventory_api(self): target = '''localhost foo=bar baz=bar [some_group] localhost foo=other 192.168.1.10 [another group] 192.168.1.10 ''' i = inventory.Inventory( ['localhost foo=bar baz=bar'], sections=[ inventory.InventoryGroup( 'some_group', ['localhost foo=other', '192.168.1.10']), inventory.InventoryGroup('another group', ['192.168.1.10']) ]) self.assertEquals(i.to_string(), target)
def test_simple_inventory_list_and_dict(self): target = inventory.Inventory(['localhost', 'localhost2'], sections=[ inventory.InventoryGroup( 'test', ['localhost', 'localhost2']) ]) source = inventory.simple_inventory( ['localhost', 'localhost2'], {"test": ["localhost", "localhost2"]}) self.assertEquals(source.to_string(), target.to_string())
def test_ansible_inventory_group_set_name(self): g = inventory.InventoryGroup('[foobar]') g.name = 'FOOBAR' self.assertEquals(g.name, 'FOOBAR') self.assertEquals(g.heading, '[FOOBAR]')
def test_ansible_inventory_group_name(self): g = inventory.InventoryGroup('[foobar]') self.assertEquals(g.heading, '[foobar]') self.assertEquals(g.name, 'foobar')