diff --git a/test/units/executor/test_play_iterator.py b/test/units/executor/test_play_iterator.py index d8e0d97e02..364ec54d43 100644 --- a/test/units/executor/test_play_iterator.py +++ b/test/units/executor/test_play_iterator.py @@ -29,6 +29,8 @@ from ansible.playbook.task import Task from ansible.playbook.play_context import PlayContext from units.mock.loader import DictDataLoader +from units.mock.path import mock_unfrackpath_noop + class TestPlayIterator(unittest.TestCase): @@ -55,7 +57,10 @@ class TestPlayIterator(unittest.TestCase): new_hs = hs.copy() + + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_play_iterator(self): + #import epdb; epdb.st() fake_loader = DictDataLoader({ "test_play.yml": """ - hosts: all diff --git a/test/units/mock/path.py b/test/units/mock/path.py new file mode 100644 index 0000000000..f46b7c8a9d --- /dev/null +++ b/test/units/mock/path.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +def mock_unfrackpath_noop(path): + ''' Do not expand the path ''' + return path diff --git a/test/units/playbook/test_play.py b/test/units/playbook/test_play.py index fc30d13872..bb47ee418b 100644 --- a/test/units/playbook/test_play.py +++ b/test/units/playbook/test_play.py @@ -28,6 +28,8 @@ from ansible.playbook.play import Play from ansible.playbook.role import Role from units.mock.loader import DictDataLoader +from units.mock.path import mock_unfrackpath_noop + class TestPlay(unittest.TestCase): @@ -102,6 +104,7 @@ class TestPlay(unittest.TestCase): post_tasks=[dict(action='shell echo "hello world"')], )) + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_play_with_roles(self): fake_loader = DictDataLoader({ '/etc/ansible/roles/foo/tasks.yml': """ diff --git a/test/units/playbook/test_role.py b/test/units/playbook/test_role.py index e0764a9b5b..8e62729303 100644 --- a/test/units/playbook/test_role.py +++ b/test/units/playbook/test_role.py @@ -29,6 +29,7 @@ from ansible.playbook.role.include import RoleInclude from ansible.playbook.task import Task from units.mock.loader import DictDataLoader +from units.mock.path import mock_unfrackpath_noop class TestRole(unittest.TestCase): @@ -38,6 +39,7 @@ class TestRole(unittest.TestCase): def tearDown(self): pass + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_load_role_with_tasks(self): fake_loader = DictDataLoader({ @@ -56,6 +58,7 @@ class TestRole(unittest.TestCase): self.assertEqual(len(r._task_blocks), 1) assert isinstance(r._task_blocks[0], Block) + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_load_role_with_handlers(self): fake_loader = DictDataLoader({ @@ -74,6 +77,7 @@ class TestRole(unittest.TestCase): self.assertEqual(len(r._handler_blocks), 1) assert isinstance(r._handler_blocks[0], Block) + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_load_role_with_vars(self): fake_loader = DictDataLoader({ @@ -94,6 +98,7 @@ class TestRole(unittest.TestCase): self.assertEqual(r._default_vars, dict(foo='bar')) self.assertEqual(r._role_vars, dict(foo='bam')) + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_load_role_with_metadata(self): fake_loader = DictDataLoader({ @@ -161,6 +166,7 @@ class TestRole(unittest.TestCase): i = RoleInclude.load('recursive1_metadata', play=mock_play, loader=fake_loader) self.assertRaises(AnsibleError, Role.load, i, play=mock_play) + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_load_role_complex(self): # FIXME: add tests for the more complex uses of diff --git a/test/units/vars/test_variable_manager.py b/test/units/vars/test_variable_manager.py index 91cb5b3f7f..c808262222 100644 --- a/test/units/vars/test_variable_manager.py +++ b/test/units/vars/test_variable_manager.py @@ -29,6 +29,7 @@ from ansible.playbook.play import Play from ansible.vars import VariableManager from units.mock.loader import DictDataLoader +from units.mock.path import mock_unfrackpath_noop class TestVariableManager(unittest.TestCase): @@ -181,6 +182,7 @@ class TestVariableManager(unittest.TestCase): self.assertEqual(v.get_vars(loader=fake_loader, task=mock_task, use_cache=False).get("foo"), "bar") @patch.object(Inventory, 'basedir') + @patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop) def test_variable_manager_precedence(self, mock_basedir): ''' Tests complex variations and combinations of get_vars() with different