Adding v2 task/block iterator and some reorganizing

This commit is contained in:
James Cammarata
2014-11-06 13:14:38 -06:00
parent 5a4a212869
commit 24bebd85b4
25 changed files with 358 additions and 49 deletions

View File

@@ -75,3 +75,9 @@ class TestBlock(unittest.TestCase):
self.assertEqual(len(b.block), 1)
assert isinstance(b.block[0], Task)
def test_block_compile(self):
ds = [dict(action='foo')]
b = Block.load(ds)
tasks = b.compile()
self.assertEqual(len(tasks), 1)
self.assertIsInstance(tasks[0], Task)

View File

@@ -117,4 +117,16 @@ class TestPlay(unittest.TestCase):
roles=['foo'],
), loader=fake_loader)
tasks = p.compile()
def test_play_compile(self):
p = Play.load(dict(
name="test play",
hosts=['foo'],
gather_facts=False,
tasks=[dict(action='shell echo "hello world"')],
))
tasks = p.compile()
self.assertEqual(len(tasks), 1)
self.assertIsInstance(tasks[0], Task)

View File

@@ -45,6 +45,7 @@ class TestPlaybook(unittest.TestCase):
""",
})
p = Playbook.load("test_file.yml", loader=fake_loader)
entries = p.get_entries()
def test_bad_playbook_files(self):
fake_loader = DictDataLoader({

View File

@@ -45,6 +45,7 @@ class TestTaskInclude(unittest.TestCase):
def test_basic_task_include(self):
ti = TaskInclude.load(AnsibleMapping(include='foo.yml'), loader=self._fake_loader)
tasks = ti.compile()
def test_task_include_with_loop(self):
ti = TaskInclude.load(AnsibleMapping(include='foo.yml', with_items=['a', 'b', 'c']), loader=self._fake_loader)