def test_milestone_patch_dateMet_when_it_already_set(self): contract, milestones = prepare_milestones_approval(self) approval_milestone = milestones[1] assert approval_milestone.type_ == 'approval' reporting_milestone = milestones[2] dueDate_to_set = approval_milestone.dueDate + timedelta(days=500) approval_dateMet = approval_milestone.dueDate - timedelta(days=5) # patch dueDate response = patch_milestone( self, contract, reporting_milestone['id'], {'data': { 'dueDate': dueDate_to_set.isoformat() }}) self.assertEqual(response.status, '200 OK') patched_reporting_milestone = get_milestone(self, contract.data.id, reporting_milestone['id']) assert patched_reporting_milestone.dueDate == dueDate_to_set, 'dueDate was not patched' response = patch_milestone( self, contract, approval_milestone['id'], {'data': { 'dateMet': approval_dateMet.isoformat() }}) reporting_milestone = get_milestone(self, contract.data.id, reporting_milestone.id) assert reporting_milestone.dueDate == dueDate_to_set, 'dueDate must not be changed'
def test_patch_approval_milestone_without_document(self): contract, milestones = prepare_milestones_approval(self) approval_milestone = milestones[1] assert approval_milestone.type_ == 'approval' dateMet_to_set = approval_milestone.dueDate - timedelta(days=5) # all milestones have documents attached, so we need to unattach one from the approval milestone approval_milestone_document_id = None for document in contract.data.documents: if document.relatedItem == approval_milestone.id: approval_milestone_document_id = document.id patch_milestone_document(self, contract, approval_milestone.id, approval_milestone_document_id, {'data': { 'relatedItem': milestones[0].id }}) # now milestone has no documents, so we are welcome to test patch_milestone(self, contract, approval_milestone.id, {'data': { 'dateMet': dateMet_to_set.isoformat() }}, status=403)
def test_patch_met_to_notMet(self): contract, milestones = prepare_milestones_approval(self) financing_milestone = Milestone(milestones[0]) assert financing_milestone.type_ == 'financing' assert financing_milestone.status == 'met' patch_milestone(self, contract, financing_milestone.id, {'data': { 'status': 'notMet' }}, status=403)
def test_upload_document_in_terminal_status(self): contract, milestones = prepare_milestones_approval(self) financing_milestone = milestones[0] # now it's in terminal status self.assertEqual(financing_milestone.type_, 'financing') self.assertEqual(financing_milestone.status, 'met') try: post_milestone_document( self, contract, financing_milestone.id, ) except AppError: return # we're looking for an exception self.fail( 'Document was uploaded in the milestone with terminal status')
def test_update_dateModified_forbidden(self): contract, milestones = prepare_milestones_approval(self) reporting_milestone = Milestone(milestones[2]) assert reporting_milestone.type_ == 'reporting' old_dateModified = reporting_milestone.dateModified patch_milestone(self, contract, reporting_milestone.id, {'data': { 'type_': '937-99-92' }}, status=422) patched_milestone = get_milestone(self, contract.data.id, reporting_milestone.id) assert old_dateModified == patched_milestone.dateModified, 'dateModified must not be updated'
def test_patch_description(self): contract, milestones = prepare_milestones_approval(self) reporting_milestone = Milestone(milestones[2]) assert reporting_milestone.type_ == 'reporting' patch_milestone( self, contract, reporting_milestone.id, {'data': { 'description': '937-99-92' }}, ) patched_milestone = get_milestone(self, contract.data.id, reporting_milestone.id) self.assertEqual(patched_milestone.description, '937-99-92')
def test_patch_status(self): contract, milestones = prepare_milestones_approval(self) reporting_milestone = Milestone(milestones[2]) assert reporting_milestone.type_ == 'reporting' patch_milestone( self, contract, reporting_milestone.id, {'data': { 'status': 'met' }}, ) patched_milestone = get_milestone(self, contract.data.id, reporting_milestone.id) self.assertEqual(patched_milestone.status, 'scheduled')
def test_update_dateModified(self): contract, milestones = prepare_milestones_approval(self) reporting_milestone = Milestone(milestones[2]) assert reporting_milestone.type_ == 'reporting' old_dateModified = reporting_milestone.dateModified patch_milestone( self, contract, reporting_milestone['id'], {'data': { 'description': '937-99-92' }}, ) patched_milestone = get_milestone(self, contract.data.id, reporting_milestone.id) assert old_dateModified != patched_milestone.dateModified, 'dateModified must be updated'
def test_milestone_patch_reporting_dueDate_when_scheduled(self): contract, milestones = prepare_milestones_approval(self) approval_milestone = milestones[1] assert approval_milestone.type_ == 'approval' reporting_milestone = milestones[2] dueDate_to_set = approval_milestone.dueDate + timedelta(days=500) response = patch_milestone( self, contract, reporting_milestone['id'], {'data': { 'dueDate': dueDate_to_set.isoformat() }}) self.assertEqual(response.status, '200 OK') patched_reporting_milestone = get_milestone(self, contract.data.id, reporting_milestone['id']) assert patched_reporting_milestone.dueDate == dueDate_to_set, 'dueDate was not patched'
def test_upload_documents_with_milestone_related_types(self): contract, milestones = prepare_milestones_approval(self) reporting_milestone = Milestone(milestones[2]) assert reporting_milestone.type_ == 'reporting' protocol_types = ('approvalProtocol', 'rejectionProtocol') for protocol_type in protocol_types: doc_id = post_milestone_document( self, contract, reporting_milestone.id, documentType=protocol_type).json['data']['id'] contract_after_post = get_contract(self, contract.data.id) found_doc = None for doc in contract_after_post.documents: if doc.id == doc_id: found_doc = doc assert found_doc, 'document was not attached to the contract' assert found_doc.documentType == protocol_type
def test_milestone_patch_approval_dateMet(self): contract, milestones = prepare_milestones_approval(self) approval_milestone = Milestone(milestones[1]) assert approval_milestone.type_ == 'approval' dateMet_to_set = approval_milestone.dueDate - timedelta(days=5) response = patch_milestone( self, contract, approval_milestone.id, {'data': { 'dateMet': dateMet_to_set.isoformat() }}) self.assertEqual(response.status, '200 OK') patched_approval_milestone = get_milestone(self, contract.data.id, approval_milestone['id']) assert patched_approval_milestone.dateMet == dateMet_to_set, 'dateMet was not set' assert patched_approval_milestone.status == 'met' reporting_milestone = get_milestone(self, contract.data.id, milestones[2]['id']) assert reporting_milestone.status == 'processing', 'Reporting milestone status must be `processing`' assert reporting_milestone.dueDate is not None updated_contract = get_contract(self, contract.data.id) assert updated_contract.status == 'active', 'Contract status was not updated'