本文整理汇总了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'])
示例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'])
示例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'])
示例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'])