本文整理汇总了Python中pulp.server.managers.consumer.agent.AgentManager.update_content方法的典型用法代码示例。如果您正苦于以下问题:Python AgentManager.update_content方法的具体用法?Python AgentManager.update_content怎么用?Python AgentManager.update_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.managers.consumer.agent.AgentManager
的用法示例。
在下文中一共展示了AgentManager.update_content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_content
# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import update_content [as 别名]
def test_update_content(self, *mocks):
mock_agent = mocks[0]
mock_context = mocks[1]
mock_factory = mocks[2]
mock_get_profiler = mocks[3]
mock_get_profiled_consumer = mocks[4]
mock_task_status = mocks[5]
mock_uuid = mocks[6]
unit = {'type_id': 'xyz', 'unit_key': {}}
consumer = {'id': '1234'}
mock_consumer_manager = Mock()
mock_consumer_manager.get_consumer = Mock(return_value=consumer)
mock_factory.consumer_manager = Mock(return_value=mock_consumer_manager)
mock_get_profiled_consumer.return_value = consumer
mock_profiler = Mock()
mock_profiler.update_units = Mock(return_value=[unit])
mock_get_profiler.return_value = (mock_profiler, {})
task_id = '2345'
mock_context.return_value = {}
mock_uuid.return_value = task_id
# test manager
options = {'a': 1}
agent_manager = AgentManager()
agent_manager.update_content(consumer['id'], [unit], options)
# validations
task_tags = [
tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer['id']),
tags.action_tag(tags.ACTION_AGENT_UNIT_UPDATE)
]
mock_consumer_manager.get_consumer.assert_called_with(consumer['id'])
mock_context.assert_called_with(consumer, task_id=task_id, consumer_id=consumer['id'])
mock_task_status.assert_called_with(task_id=task_id, worker_name='agent', tags=task_tags)
mock_profiler.update_units.assert_called_with(consumer, [unit], options, {}, ANY)
mock_agent.update.assert_called_with(mock_context.return_value, [unit], options)