diff --git a/test/units/inventory/__init__.py b/test/units/inventory/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/units/inventory/test_host.py b/test/units/plugins/inventory/test_host.py similarity index 100% rename from test/units/inventory/test_host.py rename to test/units/plugins/inventory/test_host.py diff --git a/test/units/inventory/test_inventory.py b/test/units/plugins/inventory/test_inventory.py similarity index 89% rename from test/units/inventory/test_inventory.py rename to test/units/plugins/inventory/test_inventory.py index d06865fb69..07934aa49b 100644 --- a/test/units/inventory/test_inventory.py +++ b/test/units/plugins/inventory/test_inventory.py @@ -20,10 +20,14 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import string +import textwrap +from ansible import constants as C +from ansible.compat.tests import mock from ansible.compat.tests import unittest from ansible.module_utils.six import string_types from ansible.module_utils._text import to_text +from units.mock.path import mock_unfrackpath_noop from ansible.inventory.manager import InventoryManager, split_host_pattern @@ -156,6 +160,22 @@ class IniInventory(unittest.TestCase): else: self.assertIsInstance(variables['var%s' % i], type(values[i])) + @mock.patch('ansible.inventory.manager.unfrackpath', mock_unfrackpath_noop) + @mock.patch('os.path.exists', lambda x: True) + @mock.patch('os.access', lambda x, y: True) + def test_yaml_inventory(self, filename="test.yaml"): + inventory_content = {filename: textwrap.dedent("""\ + --- + all: + hosts: + test1 + test2 + """)} + C.INVENTORY_ENABLED = ['yaml'] + fake_loader = DictDataLoader(inventory_content) + im = InventoryManager(loader=fake_loader, sources=filename) + self.assertTrue(im._inventory.hosts) + def _get_inventory(self, inventory_content): fake_loader = DictDataLoader({__file__: inventory_content})