From 993ce592b1f2ce1405b7ceff5334269e227e1a40 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 22 Jul 2015 11:30:05 -0400 Subject: [PATCH] Update unit tests for flush_handlers fix --- test/units/executor/test_play_iterator.py | 28 +++++++++++++++++++---- test/units/playbook/test_play.py | 10 ++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/test/units/executor/test_play_iterator.py b/test/units/executor/test_play_iterator.py index 700ee4c2554..3b30f9c11ca 100644 --- a/test/units/executor/test_play_iterator.py +++ b/test/units/executor/test_play_iterator.py @@ -77,19 +77,37 @@ class TestPlayIterator(unittest.TestCase): all_vars=dict(), ) + # pre task (host_state, task) = itr.get_next_task_for_host(hosts[0]) - print(task) self.assertIsNotNone(task) + self.assertEqual(task.action, 'debug') + # implicit meta: flush_handlers (host_state, task) = itr.get_next_task_for_host(hosts[0]) - print(task) self.assertIsNotNone(task) + self.assertEqual(task.action, 'meta') + # role task (host_state, task) = itr.get_next_task_for_host(hosts[0]) - print(task) self.assertIsNotNone(task) + self.assertEqual(task.action, 'debug') + self.assertIsNotNone(task._role) + # regular play task (host_state, task) = itr.get_next_task_for_host(hosts[0]) - print(task) self.assertIsNotNone(task) + self.assertEqual(task.action, 'debug') + self.assertIsNone(task._role) + # implicit meta: flush_handlers + (host_state, task) = itr.get_next_task_for_host(hosts[0]) + self.assertIsNotNone(task) + self.assertEqual(task.action, 'meta') + # post task + (host_state, task) = itr.get_next_task_for_host(hosts[0]) + self.assertIsNotNone(task) + self.assertEqual(task.action, 'debug') + # implicit meta: flush_handlers + (host_state, task) = itr.get_next_task_for_host(hosts[0]) + self.assertIsNotNone(task) + self.assertEqual(task.action, 'meta') + # end of iteration (host_state, task) = itr.get_next_task_for_host(hosts[0]) - print(task) self.assertIsNone(task) diff --git a/test/units/playbook/test_play.py b/test/units/playbook/test_play.py index 0dbac227bd4..f3fe1e07310 100644 --- a/test/units/playbook/test_play.py +++ b/test/units/playbook/test_play.py @@ -117,7 +117,7 @@ class TestPlay(unittest.TestCase): roles=['foo'], ), loader=fake_loader) - tasks = p.compile() + blocks = p.compile() def test_play_compile(self): p = Play.load(dict( @@ -127,6 +127,8 @@ class TestPlay(unittest.TestCase): tasks=[dict(action='shell echo "hello world"')], )) - tasks = p.compile() - self.assertEqual(len(tasks), 1) - self.assertIsInstance(tasks[0], Block) + blocks = p.compile() + + # with a single block, there will still be three + # implicit meta flush_handler blocks inserted + self.assertEqual(len(blocks), 4)