def test_set_terminal_status_with_allowed_role(self): contract, _ = prepare_milestones_all_met(self) self.app.authorization = ('Basic', ('caravan', '')) patch_contract( self, contract, {'data': { 'status': 'terminated' }}, ) terminated_contract = get_contract(self, contract.data.id) self.assertEqual(terminated_contract.status, 'terminated')
def test_patch_contract_forbidden_status(self): contract = create_contract(self) # set allowed status patch_contract( self, contract, {'data': { 'status': 'active.payment' }}, ) patch_contract(self, contract, {'data': { 'status': 'active.approval' }}, status=403)
def test_patch_contract_status_active_payment(self): contract = create_contract(self) response = patch_contract( self, contract, {'data': { 'status': 'active.payment' }}, ) self.assertEqual(response.status, '200 OK') response_data = response.json['data'] self.assertEqual(response_data['status'], 'active.payment') self.assertTrue(isinstance(response_data.get('milestones'), list), "Milestones weren't created") financial_milestone = response_data['milestones'][0] contract = Contract(contract_create_data) target_dueDate = calculate_business_date( contract.dateSigned, MILESTONE_FINANCING_DUEDATE_OFFSET, context=None, working_days=False, specific_hour=18, result_is_working_day=True) self.assertEqual( financial_milestone['dueDate'], target_dueDate.isoformat(), "dueDate of financial milestone wasn't calculated right")
def test_patch_internal_type(self): contract = create_contract(self) # set allowed status response = patch_contract(self, contract, {'data': { '_internal_type': 'lucy_lu' }}, status=422) self.assertEqual(response.status, '422 Unprocessable Entity')
def test_patch_response_have_not_excessive_fields(self): contract = create_contract(self) response = patch_contract( self, contract, {'data': { 'status': 'active.payment' }}, ) self.assertEqual(response.status, '200 OK') response_data_keys = response.json['data'].keys() self.check_forbidden_contract_fields(response_data_keys)