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


Python AgentManager._unbindings方法代码示例

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


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

示例1: test_get_agent_unbindings

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import _unbindings [as 别名]
    def test_get_agent_unbindings(self, m_model):
        distributor = model.Distributor(distributor_type_id='3838')
        m_model.Distributor.objects.get_or_404.return_value = distributor

        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        for binding in bindings:
            m_model.Distributor.objects.get_or_404.assert_any_call(
                repo_id=binding['repo_id'], distributor_id=binding['distributor_id'])

        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(distributor['distributor_type_id'], agent_binding['type_id'])
开发者ID:alanoe,项目名称:pulp,代码行数:20,代码来源:test_agent.py

示例2: test_get_agent_unbindings_distributor_deleted

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import _unbindings [as 别名]
    def test_get_agent_unbindings_distributor_deleted(self, m_model):
        """
        Test that AgentManager._unbindings does not raise an exception when the distributor is
        deleted and returns None as the distributor_type_id.
        """
        m_model.Distributor.objects.get_or_404.side_effect = MissingResource
        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        # validation
        self.assertTrue(m_model.Distributor.objects.get_or_404.called)
        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(None, agent_binding['type_id'])
开发者ID:alanoe,项目名称:pulp,代码行数:20,代码来源:test_agent.py

示例3: test_get_agent_unbindings_distributor_deleted

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import _unbindings [as 别名]
    def test_get_agent_unbindings_distributor_deleted(self, mock_repo_distributor_manager):
        # Test that AgentManager._unbindings does not raise an exception
        # when the distributor is deleted and returns None as the distributor_type_id.
        def test_get_distributor():
            raise MissingResource()
        mock_repo_distributor_manager.get_distributor = test_get_distributor

        # test
        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        # validation
        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(None, agent_binding['type_id'])
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:21,代码来源:test_agent_manager.py

示例4: test_get_agent_unbindings

# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import _unbindings [as 别名]
    def test_get_agent_unbindings(self, mock_factory):
        distributor = {'distributor_type_id': '3838'}
        mock_distributor_manager = Mock()
        mock_distributor_manager.get_distributor = Mock(return_value=distributor)
        mock_factory.repo_distributor_manager = Mock(return_value=mock_distributor_manager)

        # test manager

        bindings = [
            {'consumer_id': '10', 'repo_id': '20', 'distributor_id': '30', 'binding_config': {}},
            {'consumer_id': '40', 'repo_id': '50', 'distributor_id': '60', 'binding_config': {}},
        ]
        agent_bindings = AgentManager._unbindings(bindings)

        # validation

        for binding in bindings:
            mock_distributor_manager.get_distributor.assert_any_call(
                binding['repo_id'], binding['distributor_id'])

        self.assertEqual(len(agent_bindings), 2)
        for binding, agent_binding in itertools.izip(bindings, agent_bindings):
            self.assertEqual(binding['repo_id'], agent_binding['repo_id'])
            self.assertEqual(distributor['distributor_type_id'], agent_binding['type_id'])
开发者ID:signull,项目名称:pulp,代码行数:26,代码来源:test_agent_manager.py


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