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


Python AgentManager.unbind方法代码示例

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


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

示例1: test_unbind

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import unbind [as 别名]
    def test_unbind(self, *mocks):
        mock_agent = mocks[0]
        mock_context = mocks[1]
        mock_factory = mocks[2]
        mock_unbindings = mocks[3]
        mock_task_status = mocks[4]
        mock_uuid = mocks[5]

        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)

        repo_id = '100'
        distributor_id = '200'
        binding = {'repo_id': repo_id, 'distributor_id': distributor_id}
        mock_bind_manager = Mock()
        mock_bind_manager.action_pending = Mock()
        mock_factory.consumer_bind_manager = Mock(return_value=mock_bind_manager)

        agent_bindings = []
        mock_unbindings.return_value = agent_bindings

        task_id = '2345'
        mock_context.return_value = {}
        mock_uuid.return_value = task_id

        # test manager

        options = {}
        agent_manager = AgentManager()
        agent_manager.unbind(consumer['id'], repo_id, distributor_id, options)

        # validations

        task_tags = [
            tags.resource_tag(tags.RESOURCE_CONSUMER_TYPE, consumer['id']),
            tags.resource_tag(tags.RESOURCE_REPOSITORY_TYPE, repo_id),
            tags.resource_tag(tags.RESOURCE_REPOSITORY_DISTRIBUTOR_TYPE, distributor_id),
            tags.action_tag(tags.ACTION_AGENT_UNBIND)
        ]

        mock_consumer_manager.get_consumer.assert_called_with(consumer['id'])
        mock_unbindings.assert_called_with([binding])

        mock_context.assert_called_with(
            consumer,
            task_id=task_id,
            action='unbind',
            consumer_id=consumer['id'],
            repo_id=repo_id,
            distributor_id=distributor_id)

        mock_task_status.assert_called_with(task_id=task_id, worker_name='agent', tags=task_tags)
        mock_agent.unbind.assert_called_with(mock_context.return_value, agent_bindings, options)
        mock_bind_manager.action_pending.assert_called_with(
            consumer['id'], repo_id, distributor_id, Bind.Action.UNBIND, task_id)
开发者ID:alanoe,项目名称:pulp,代码行数:59,代码来源:test_agent.py


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