Commit 993ce592 by James Cammarata

Update unit tests for flush_handlers fix

parent 4b6525fb
...@@ -77,19 +77,37 @@ class TestPlayIterator(unittest.TestCase): ...@@ -77,19 +77,37 @@ class TestPlayIterator(unittest.TestCase):
all_vars=dict(), all_vars=dict(),
) )
# pre task
(host_state, task) = itr.get_next_task_for_host(hosts[0]) (host_state, task) = itr.get_next_task_for_host(hosts[0])
print(task)
self.assertIsNotNone(task) self.assertIsNotNone(task)
self.assertEqual(task.action, 'debug')
# implicit meta: flush_handlers
(host_state, task) = itr.get_next_task_for_host(hosts[0]) (host_state, task) = itr.get_next_task_for_host(hosts[0])
print(task)
self.assertIsNotNone(task) self.assertIsNotNone(task)
self.assertEqual(task.action, 'meta')
# role task
(host_state, task) = itr.get_next_task_for_host(hosts[0]) (host_state, task) = itr.get_next_task_for_host(hosts[0])
print(task)
self.assertIsNotNone(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]) (host_state, task) = itr.get_next_task_for_host(hosts[0])
print(task)
self.assertIsNotNone(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]) (host_state, task) = itr.get_next_task_for_host(hosts[0])
print(task)
self.assertIsNone(task) self.assertIsNone(task)
...@@ -117,7 +117,7 @@ class TestPlay(unittest.TestCase): ...@@ -117,7 +117,7 @@ class TestPlay(unittest.TestCase):
roles=['foo'], roles=['foo'],
), loader=fake_loader) ), loader=fake_loader)
tasks = p.compile() blocks = p.compile()
def test_play_compile(self): def test_play_compile(self):
p = Play.load(dict( p = Play.load(dict(
...@@ -127,6 +127,8 @@ class TestPlay(unittest.TestCase): ...@@ -127,6 +127,8 @@ class TestPlay(unittest.TestCase):
tasks=[dict(action='shell echo "hello world"')], tasks=[dict(action='shell echo "hello world"')],
)) ))
tasks = p.compile() blocks = p.compile()
self.assertEqual(len(tasks), 1)
self.assertIsInstance(tasks[0], Block) # with a single block, there will still be three
# implicit meta flush_handler blocks inserted
self.assertEqual(len(blocks), 4)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment