本文整理汇总了Python中pyon.core.bootstrap.IonObject.proposal_status方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject.proposal_status方法的具体用法?Python IonObject.proposal_status怎么用?Python IonObject.proposal_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.core.bootstrap.IonObject
的用法示例。
在下文中一共展示了IonObject.proposal_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_negotiation
# 需要导入模块: from pyon.core.bootstrap import IonObject [as 别名]
# 或者: from pyon.core.bootstrap.IonObject import proposal_status [as 别名]
def test_create_negotiation(self):
self.preconditions.check_method1.return_value = True
self.preconditions.check_method2.return_value = False
self.accept_actions.accept_method.return_value = None
negotiation_rules = {
OT.EnrollmentProposal: {
'pre_conditions': ['preconditions.check_method1(sap.consumer)', 'not preconditions.check_method2(sap.provider,sap.consumer)'],
'accept_action': 'accept_actions.accept_method(sap.provider,sap.consumer)'
}}
negotiation_handler = Negotiation(self, negotiation_rules)
with self.assertRaises(BadRequest) as cm:
negotiation_handler.create_negotiation()
self.assertIn('The sap parameter must be a valid Service Agreement Proposal object',cm.exception.message)
sap = IonObject(OT.EnrollmentProposal,consumer=self.actor_identity._id, provider=self.org._id )
sap.sequence_num = 1 #Force an error
with self.assertRaises(Inconsistent) as cm:
negotiation_handler.create_negotiation(sap)
self.assertIn('The specified Service Agreement Proposal has inconsistent status fields',cm.exception.message)
sap = IonObject(OT.EnrollmentProposal,consumer=self.actor_identity._id, provider=self.org._id )
sap.proposal_status = ProposalStatusEnum.COUNTER #Force an error
with self.assertRaises(Inconsistent) as cm:
negotiation_handler.create_negotiation(sap)
self.assertIn('The specified Service Agreement Proposal has inconsistent status fields',cm.exception.message)
sap = IonObject(OT.EnrollmentProposal,consumer=self.actor_identity._id, provider=self.org._id )
sap.negotiation_id = 'efefeff' #Force an error
with self.assertRaises(Inconsistent) as cm:
negotiation_handler.create_negotiation(sap)
self.assertIn('The specified Service Agreement Proposal cannot have a negotiation_id for an initial proposal',cm.exception.message)
sap = IonObject(OT.EnrollmentProposal,consumer=self.actor_identity._id, provider=self.org._id )
negotiation = Mock()
negotiation._id = '456'
negotiation.type_ = RT.Negotiation
negotiation.proposals = []
self.mock_read.return_value = negotiation
self.mock_create.return_value = ['456', 2]
neg_id = negotiation_handler.create_negotiation(sap)
self.assertEqual(neg_id, negotiation._id)
self.assertEqual(len(negotiation.proposals),0)
self.assertEqual(self.preconditions.check_method1.called,True)
self.assertEqual(self.preconditions.check_method2.called,True)
self.assertEqual(self.accept_actions.accept_method.called,False)