def apply_prolongation_short(test_case): pre_prolongation_contract = get_related_contract(test_case) add_document_to_prolongation( test_case, test_case.auction_id, test_case.contract_id, test_case.prolongation_id, ) patch_data = { 'data': { 'status': 'applied', } } patch_prolongation_response = test_case.app.patch_json( PATHS['prolongation'].format( auction_id=test_case.auction_id, contract_id=test_case.contract_id, prolongation_id=test_case.prolongation_id, token=test_case.auction_token ), patch_data ) test_case.assertEqual( patch_prolongation_response.status, '200 OK' ) retrieved_prolongation = Prolongation( patch_prolongation_response.json['data'] ) retrieved_prolongation.validate() test_case.assertEqual( retrieved_prolongation.status, 'applied' ) add_document_to_prolongation( test_case, test_case.auction_id, test_case.contract_id, test_case.prolongation_id, ) post_prolongation_contract = get_related_contract(test_case) auction = get_auction(test_case) contract_signing_period_end_date = calculate_business_date( pre_prolongation_contract.signingPeriod.startDate, PROLONGATION_SHORT_PERIOD, context=auction, working_days=True, specific_hour=CONTRACT_SIGNING_PERIOD_END_DATE_HOUR ) test_case.assertEqual( post_prolongation_contract.signingPeriod.endDate, contract_signing_period_end_date )
def apply_prolongation_triple_times(test_case): pre_prolongation_contract = get_related_contract(test_case) add_document_to_prolongation( test_case, test_case.auction_id, test_case.contract_id, test_case.prolongation_id, ) add_document_to_prolongation( test_case, test_case.auction_id, test_case.contract_id, test_case.prolongation2_id, ) add_document_to_prolongation( test_case, test_case.auction_id, test_case.contract_id, test_case.prolongation3_id, ) patch_data = { 'data': { 'status': 'applied', } } # apply some short prolongation to be able apply long one short_prolongation_patch_response = test_case.app.patch_json( PATHS['prolongation'].format(auction_id=test_case.auction_id, contract_id=test_case.contract_id, prolongation_id=test_case.prolongation_id, token=test_case.auction_token), patch_data) # apply long prolongation test_case.app.patch_json( PATHS['prolongation'].format( auction_id=test_case.auction_id, contract_id=test_case.contract_id, prolongation_id=test_case.prolongation2_id, token=test_case.auction_token), patch_data) third_patch_prolongation_response = test_case.app.patch_json( PATHS['prolongation'].format( auction_id=test_case.auction_id, contract_id=test_case.contract_id, prolongation_id=test_case.prolongation3_id, token=test_case.auction_token), patch_data, status=403) test_case.assertEqual(third_patch_prolongation_response.status, '403 Forbidden') test_case.assertEqual(third_patch_prolongation_response.content_type, 'application/json') test_case.assertEqual( third_patch_prolongation_response.json['errors'][0]["description"], "Contract can be prolongated for 2 times only.") # check if contract signing was prolongated for the third time post_prolongation_contract = get_related_contract(test_case) auction = get_auction(test_case) contract_signing_period_end_date = calculate_business_date( pre_prolongation_contract.signingPeriod.startDate, PROLONGATION_LONG_PERIOD, context=auction, working_days=True, specific_hour=CONTRACT_SIGNING_PERIOD_END_DATE_HOUR) test_case.assertEqual(post_prolongation_contract.signingPeriod.endDate, contract_signing_period_end_date)