本文整理汇总了Python中ansible.executor.task_queue_manager.TaskQueueManager._initialize_notified_handlers方法的典型用法代码示例。如果您正苦于以下问题:Python TaskQueueManager._initialize_notified_handlers方法的具体用法?Python TaskQueueManager._initialize_notified_handlers怎么用?Python TaskQueueManager._initialize_notified_handlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.executor.task_queue_manager.TaskQueueManager
的用法示例。
在下文中一共展示了TaskQueueManager._initialize_notified_handlers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_strategy_base_run_handlers
# 需要导入模块: from ansible.executor.task_queue_manager import TaskQueueManager [as 别名]
# 或者: from ansible.executor.task_queue_manager.TaskQueueManager import _initialize_notified_handlers [as 别名]
def test_strategy_base_run_handlers(self, mock_worker):
def fake_run(*args):
return
mock_worker.side_effect = fake_run
mock_play_context = MagicMock()
mock_handler_task = MagicMock(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 = MagicMock()
mock_handler.block = [mock_handler_task]
mock_handler.flag_for_host.return_value = False
mock_play = MagicMock()
mock_play.handlers = [mock_handler]
mock_host = MagicMock(Host)
mock_host.name = "test01"
mock_host.has_hostkey = True
mock_inventory = MagicMock()
mock_inventory.get_hosts.return_value = [mock_host]
mock_var_mgr = MagicMock()
mock_var_mgr.get_vars.return_value = dict()
mock_iterator = MagicMock
mock_iterator._play = mock_play
fake_loader = DictDataLoader()
mock_options = MagicMock()
mock_options.module_path = None
tqm = TaskQueueManager(
inventory=mock_inventory,
variable_manager=mock_var_mgr,
loader=fake_loader,
options=mock_options,
passwords=None,
)
tqm._initialize_processes(3)
tqm._initialize_notified_handlers(mock_play)
tqm.hostvars = dict()
try:
strategy_base = StrategyBase(tqm=tqm)
strategy_base._inventory = mock_inventory
strategy_base._notified_handlers = {mock_handler_task: [mock_host]}
task_result = TaskResult(Host('host01'), Handler(), dict(changed=False))
tqm._final_q.put(('host_task_ok', task_result))
result = strategy_base.run_handlers(iterator=mock_iterator, play_context=mock_play_context)
finally:
tqm.cleanup()