diff options
author | Matt Martz <matt@sivel.net> | 2018-12-11 16:58:19 +0100 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2018-12-11 16:58:19 +0100 |
commit | 2a469fd9597ac36099e991a1757193e6d3016e63 (patch) | |
tree | ef05cea96df424db851c578765010c7936e1c951 /test/units/plugins/strategy | |
parent | Add DellEMC iDRAC Firmware module (#46675) (diff) | |
download | ansible-2a469fd9597ac36099e991a1757193e6d3016e63.tar.xz ansible-2a469fd9597ac36099e991a1757193e6d3016e63.zip |
Consolidate handler tracking (#49338)
* Consolidate handler tracking
- Remove unused code. ci_complete
- unit test fixes. ci_complete
- Restore previous behavior of matching a single handler
- when notifying a host for a handler, return True if it was added, False otherwise, to reduce copied logic
- rename funcitons for clarity. ci_complete
- Remove handler logic for static includes which was disabled previously
Diffstat (limited to 'test/units/plugins/strategy')
-rw-r--r-- | test/units/plugins/strategy/test_strategy_base.py | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/test/units/plugins/strategy/test_strategy_base.py b/test/units/plugins/strategy/test_strategy_base.py index 57f615125c..85a5d24017 100644 --- a/test/units/plugins/strategy/test_strategy_base.py +++ b/test/units/plugins/strategy/test_strategy_base.py @@ -67,8 +67,6 @@ class TestStrategyBase(unittest.TestCase): mock_tqm = MagicMock(TaskQueueManager) mock_tqm._final_q = mock_queue mock_tqm._options = MagicMock() - mock_tqm._notified_handlers = {} - mock_tqm._listening_handlers = {} strategy_base = StrategyBase(tqm=mock_tqm) strategy_base.cleanup() @@ -95,8 +93,6 @@ class TestStrategyBase(unittest.TestCase): mock_tqm = MagicMock(TaskQueueManager) mock_tqm._final_q = mock_queue mock_tqm._stats = MagicMock() - mock_tqm._notified_handlers = {} - mock_tqm._listening_handlers = {} mock_tqm.send_callback.return_value = None for attr in ('RUN_OK', 'RUN_ERROR', 'RUN_FAILED_HOSTS', 'RUN_UNREACHABLE_HOSTS'): @@ -111,8 +107,6 @@ class TestStrategyBase(unittest.TestCase): mock_tqm._failed_hosts = dict() mock_tqm._unreachable_hosts = dict() mock_tqm._options = MagicMock() - mock_tqm._notified_handlers = {} - mock_tqm._listening_handlers = {} strategy_base = StrategyBase(tqm=mock_tqm) mock_host = MagicMock() @@ -160,8 +154,6 @@ class TestStrategyBase(unittest.TestCase): mock_tqm = MagicMock() mock_tqm._final_q = mock_queue - mock_tqm._notified_handlers = {} - mock_tqm._listening_handlers = {} mock_tqm.get_inventory.return_value = mock_inventory mock_play = MagicMock() @@ -231,8 +223,6 @@ class TestStrategyBase(unittest.TestCase): mock_tqm._failed_hosts = dict() mock_tqm._unreachable_hosts = dict() mock_tqm.send_callback.return_value = None - mock_tqm._notified_handlers = {} - mock_tqm._listening_handlers = {} queue_items = [] @@ -274,14 +264,11 @@ class TestStrategyBase(unittest.TestCase): mock_task.loop = None mock_task.copy.return_value = mock_task - mock_handler_task = MagicMock(Handler) + mock_handler_task = Handler() mock_handler_task.name = 'test handler' mock_handler_task.action = 'foo' mock_handler_task._parent = None - mock_handler_task.get_name.return_value = "test handler" - mock_handler_task.has_triggered.return_value = False mock_handler_task._uuid = 'xxxxxxxxxxxxx' - mock_handler_task.copy.return_value = mock_handler_task mock_iterator = MagicMock() mock_iterator._play = mock_play @@ -294,9 +281,6 @@ class TestStrategyBase(unittest.TestCase): mock_handler_block.always = [] mock_play.handlers = [mock_handler_block] - mock_tqm._notified_handlers = {mock_handler_task._uuid: []} - mock_tqm._listening_handlers = {} - mock_group = MagicMock() mock_group.add_host.return_value = None @@ -422,8 +406,7 @@ class TestStrategyBase(unittest.TestCase): self.assertEqual(len(results), 1) self.assertEqual(strategy_base._pending_results, 0) self.assertNotIn('test01', strategy_base._blocked_hosts) - self.assertIn(mock_handler_task._uuid, strategy_base._notified_handlers) - self.assertIn(mock_host, strategy_base._notified_handlers[mock_handler_task._uuid]) + self.assertTrue(mock_handler_task.is_host_notified(mock_host)) # queue_items.append(('set_host_var', mock_host, mock_task, None, 'foo', 'bar')) # results = strategy_base._process_pending_results(iterator=mock_iterator) @@ -469,8 +452,6 @@ class TestStrategyBase(unittest.TestCase): mock_tqm = MagicMock() mock_tqm._final_q = mock_queue - mock_tqm._notified_handlers = {} - mock_tqm._listening_handlers = {} strategy_base = StrategyBase(tqm=mock_tqm) strategy_base._loader = fake_loader @@ -507,15 +488,14 @@ class TestStrategyBase(unittest.TestCase): mock_worker.side_effect = fake_run mock_play_context = MagicMock() - mock_handler_task = MagicMock(Handler) + mock_handler_task = Handler() mock_handler_task.action = 'foo' - mock_handler_task.get_name.return_value = "test handler" - mock_handler_task.has_triggered.return_value = False - mock_handler_task.listen = None + mock_handler_task.cached_name = False + mock_handler_task.name = "test handler" + mock_handler_task.listen = [] mock_handler_task._role = None mock_handler_task._parent = None mock_handler_task._uuid = 'xxxxxxxxxxxxxxxx' - mock_handler_task.copy.return_value = mock_handler_task mock_handler = MagicMock() mock_handler.block = [mock_handler_task] @@ -558,7 +538,6 @@ class TestStrategyBase(unittest.TestCase): strategy_base = StrategyBase(tqm=tqm) strategy_base._inventory = mock_inventory - strategy_base._notified_handlers = {mock_handler_task._uuid: [mock_host]} task_result = TaskResult(mock_host.name, mock_handler_task._uuid, dict(changed=False)) strategy_base._queued_task_cache = dict() |