Commit 157d21b1 by Michael DeHaan

Add tests for new advanced inventory features (groups of groups, group…

Add tests for new advanced inventory features (groups of groups, group variables) in the default INI format file.
parent 1a00e263
...@@ -57,6 +57,6 @@ class Host(object): ...@@ -57,6 +57,6 @@ class Host(object):
results.update(self.vars) results.update(self.vars)
results['inventory_hostname'] = self.name results['inventory_hostname'] = self.name
groups = self.get_groups() groups = self.get_groups()
results['group_names'] = [ g.name for g in groups if g.name != 'all'] results['group_names'] = sorted([ g.name for g in groups if g.name != 'all'])
return results return results
...@@ -119,7 +119,7 @@ class Inventory(object): ...@@ -119,7 +119,7 @@ class Inventory(object):
results = utils.parse_json(out) results = utils.parse_json(out)
results['inventory_hostname'] = hostname results['inventory_hostname'] = hostname
groups = [ g.name for g in host.get_groups() if g.name != 'all' ] groups = [ g.name for g in host.get_groups() if g.name != 'all' ]
results['group_names'] = groups results['group_names'] = sorted(groups)
return results return results
host = self.get_host(hostname) host = self.get_host(hostname)
......
...@@ -11,9 +11,10 @@ class TestInventory(unittest.TestCase): ...@@ -11,9 +11,10 @@ class TestInventory(unittest.TestCase):
self.cwd = os.getcwd() self.cwd = os.getcwd()
self.test_dir = os.path.join(self.cwd, 'test') self.test_dir = os.path.join(self.cwd, 'test')
self.inventory_file = os.path.join(self.test_dir, 'simple_hosts')