本文整理汇总了Python中pyon.core.bootstrap.IonObject.negotiation_id方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject.negotiation_id方法的具体用法?Python IonObject.negotiation_id怎么用?Python IonObject.negotiation_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.core.bootstrap.IonObject
的用法示例。
在下文中一共展示了IonObject.negotiation_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_counter_proposal
# 需要导入模块: from pyon.core.bootstrap import IonObject [as 别名]
# 或者: from pyon.core.bootstrap.IonObject import negotiation_id [as 别名]
def test_create_counter_proposal(self):
with self.assertRaises(BadRequest) as cm:
consumer_accept_sap = Negotiation.create_counter_proposal(proposal_status=ProposalStatusEnum.INITIAL)
self.assertIn('The negotiation parameter must be a valid Negotiation object',cm.exception.message)
negotiation_handler = Negotiation(self)
sap = IonObject(OT.EnrollmentProposal,consumer=self.actor_identity._id, provider=self.org._id )
negotiation = Mock()
negotiation._id = '456'
negotiation.type_ = RT.Negotiation
negotiation.proposals = [sap]
self.mock_read.return_value = negotiation
self.mock_create.return_value = ['456', 2]
neg_id = negotiation_handler.create_negotiation(sap)
sap.negotiation_id = neg_id
consumer_accept_sap = Negotiation.create_counter_proposal(negotiation, proposal_status=ProposalStatusEnum.COUNTER,
originator=ProposalOriginatorEnum.PROVIDER)
self.assertEqual(consumer_accept_sap.negotiation_id, negotiation._id)
self.assertEqual(len(negotiation.proposals),1)
self.assertEqual(consumer_accept_sap.sequence_num, len(negotiation.proposals))
self.assertEqual(consumer_accept_sap.proposal_status, ProposalStatusEnum.COUNTER)
self.assertEqual(consumer_accept_sap.originator, ProposalOriginatorEnum.PROVIDER)
示例2: test_create_negotiation
# 需要导入模块: from pyon.core.bootstrap import IonObject [as 别名]
# 或者: from pyon.core.bootstrap.IonObject import negotiation_id [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)
示例3: test_read_negotiation
# 需要导入模块: from pyon.core.bootstrap import IonObject [as 别名]
# 或者: from pyon.core.bootstrap.IonObject import negotiation_id [as 别名]
def test_read_negotiation(self):
negotiation_handler = Negotiation(self)
with self.assertRaises(BadRequest) as cm:
negotiation_handler.read_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 )
with self.assertRaises(BadRequest) as cm:
negotiation_handler.read_negotiation(sap)
self.assertIn('The Service Agreement Proposal object (sap) is missing a negotiation_id value',cm.exception.message)
negotiation = Mock()
negotiation._id = '456'
sap.negotiation_id = negotiation._id
self.mock_read.return_value = negotiation
neg_obj = negotiation_handler.read_negotiation(sap)
self.assertEqual(neg_obj, negotiation)
示例4: test_update_negotiation
# 需要导入模块: from pyon.core.bootstrap import IonObject [as 别名]
# 或者: from pyon.core.bootstrap.IonObject import negotiation_id [as 别名]
def test_update_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, self.event_pub)
with self.assertRaises(Inconsistent) as cm:
negotiation_handler.update_negotiation()
self.assertIn('The Service Agreement Proposal must have a negotiation resource id associated with it',cm.exception.message)
sap = IonObject(OT.EnrollmentProposal,consumer=self.actor_identity._id, provider=self.org._id )
with self.assertRaises(Inconsistent) as cm:
negotiation_handler.update_negotiation(sap)
self.assertIn('The Service Agreement Proposal must have a negotiation resource id associated with it',cm.exception.message)
negotiation = Mock()
negotiation._id = '456'
negotiation.type_ = RT.Negotiation
negotiation.proposals = []
sap.negotiation_id = negotiation._id
self.mock_read.return_value = negotiation
self.mock_update.return_value = ['456', 2]
neg_id = negotiation_handler.update_negotiation(sap)
self.assertEqual(self.event_pub.publish_event.called,True)
self.assertEqual(neg_id, negotiation._id)
self.assertEqual(len(negotiation.proposals),1)
counter_sap = Negotiation.create_counter_proposal(negotiation, ProposalStatusEnum.REJECTED, ProposalOriginatorEnum.PROVIDER)
neg_id = negotiation_handler.update_negotiation(counter_sap, 'Fake rejection reason')
self.assertEqual(len(negotiation.proposals),2)
self.assertEqual(negotiation.negotiation_status, NegotiationStatusEnum.REJECTED)
self.assertEquals(negotiation.reason, 'Fake rejection reason' )
counter_sap = Negotiation.create_counter_proposal(negotiation, ProposalStatusEnum.ACCEPTED, ProposalOriginatorEnum.PROVIDER)
neg_id = negotiation_handler.update_negotiation(counter_sap)
self.assertEqual(len(negotiation.proposals),3)
self.assertEqual(negotiation.negotiation_status, NegotiationStatusEnum.REJECTED)
counter_sap = Negotiation.create_counter_proposal(negotiation, ProposalStatusEnum.ACCEPTED, ProposalOriginatorEnum.CONSUMER)
neg_id = negotiation_handler.update_negotiation(counter_sap)
self.assertEqual(len(negotiation.proposals),4)
self.assertEqual(negotiation.negotiation_status, NegotiationStatusEnum.ACCEPTED)
self.assertEqual(self.accept_actions.accept_method.called,True)