|
|
|
@ -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
|
|
|
|
|