当前位置: 首页>>代码示例>>Python>>正文


Python AgentManager.uninstall_content方法代码示例

本文整理汇总了Python中pulp.server.managers.consumer.agent.AgentManager.uninstall_content方法的典型用法代码示例。如果您正苦于以下问题:Python AgentManager.uninstall_content方法的具体用法?Python AgentManager.uninstall_content怎么用?Python AgentManager.uninstall_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp.server.managers.consumer.agent.AgentManager的用法示例。


在下文中一共展示了AgentManager.uninstall_content方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_uninstall_content

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import uninstall_content [as 别名]
    def test_uninstall_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.uninstall_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.uninstall_content(consumer['id'], [unit], options)

        # validations

        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer['id']),
            tags.action_tag(tags.ACTION_AGENT_UNIT_UNINSTALL)
        ]

        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.uninstall_units.assert_called_with(consumer, [unit], options, {}, ANY)
        mock_agent.uninstall.assert_called_with(mock_context.return_value, [unit], options)
        mock_factory.consumer_history_manager().record_event.assert_called_with(
            consumer['id'], 'content_unit_uninstalled', {'units': [unit]})
开发者ID:alanoe,项目名称:pulp,代码行数:48,代码来源:test_agent.py

示例2: test_uninstall_content

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import uninstall_content [as 别名]
    def test_uninstall_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_manager = 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.uninstall_units = Mock(return_value=[unit])
        mock_get_profiler.return_value = (mock_profiler, {})

        task_id = '2345'
        mock_task = {'task_id': task_id}
        mock_task_status_manager.create_task_status = Mock(return_value=mock_task)

        mock_context.return_value = {}

        mock_uuid.return_value = task_id

        # test manager

        options = {'a': 1}
        agent_manager = AgentManager()
        task = agent_manager.uninstall_content(consumer['id'], [unit], options)

        # validations

        tags = [
            resource_tag(dispatch_constants.RESOURCE_CONSUMER_TYPE, consumer['id']),
            action_tag(ACTION_AGENT_UNIT_UNINSTALL)
        ]

        self.assertEqual(task, mock_task)
        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_manager.create_task_status.assert_called_with(task_id, 'agent', tags=tags)
        mock_profiler.uninstall_units.assert_called_with(consumer, [unit], options, {}, ANY)
        mock_agent.uninstall.assert_called_with(mock_context.return_value, [unit], options)
开发者ID:signull,项目名称:pulp,代码行数:51,代码来源:test_agent_manager.py


注:本文中的pulp.server.managers.consumer.agent.AgentManager.uninstall_content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。