本文整理汇总了Python中pulp.server.managers.consumer.agent.AgentManager._bindings方法的典型用法代码示例。如果您正苦于以下问题:Python AgentManager._bindings方法的具体用法?Python AgentManager._bindings怎么用?Python AgentManager._bindings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulp.server.managers.consumer.agent.AgentManager
的用法示例。
在下文中一共展示了AgentManager._bindings方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_agent_bindings
# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import _bindings [as 别名]
def test_get_agent_bindings(self, mock_factory):
bind_payload = {'a': 1, 'b': 2}
distributor = {'distributor_type_id': '3838'}
mock_distributor_manager = Mock()
mock_distributor_manager.get_distributor = Mock(return_value=distributor)
mock_distributor_manager.create_bind_payload = Mock(return_value=bind_payload)
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._bindings(bindings)
# validation
for binding in bindings:
mock_distributor_manager.get_distributor.assert_any_call(
binding['repo_id'], binding['distributor_id'])
mock_distributor_manager.create_bind_payload.assert_any_call(
binding['repo_id'], binding['distributor_id'], binding['binding_config'])
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'])
self.assertEqual(bind_payload, agent_binding['details'])
示例2: test_get_agent_bindings
# 需要导入模块: from pulp.server.managers.consumer.agent import AgentManager [as 别名]
# 或者: from pulp.server.managers.consumer.agent.AgentManager import _bindings [as 别名]
def test_get_agent_bindings(self, m_model, m_dist_cont):
bind_payload = {'a': 1, 'b': 2}
distributor = model.Distributor(distributor_type_id='3838')
m_model.Distributor.objects.get_or_404.return_value = distributor
m_dist_cont.create_bind_payload = Mock(return_value=bind_payload)
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._bindings(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'])
m_dist_cont.create_bind_payload.assert_any_call(
binding['repo_id'], binding['distributor_id'], binding['binding_config'])
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'])
self.assertEqual(bind_payload, agent_binding['details'])