Exemplo n.º 1
0
def patch_prolongation_fields(test_case):
    patch_data = {
        'data': {
            'description': 'This Prolongation was updated!',
            'reason': 'dgfLackOfDocuments'
        }
    }
    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.description,
        patch_data['data']['description']
    )
Exemplo n.º 2
0
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 get_prolongation_by_id(test_case):
    get_prolongation_response = test_case.app.get(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))
    test_case.assertEqual(get_prolongation_response.status, '200 OK')
    # check data
    retrieved_prolongation = Prolongation(
        get_prolongation_response.json['data'])
    retrieved_prolongation.validate()
    test_case.assertEqual(retrieved_prolongation.id, test_case.prolongation_id)
def create_prolongation(test_case, test_case_attr):
    """Create prolongation and place it's id into test_case arrtibute
    """
    prolongation_post_response = test_case.app.post_json(
        '/auctions/{0}/contracts/{1}/prolongations'.format(
            test_case.auction_id, test_case.contract_id),
        {'data': PROLONGATION})
    test_case.assertEqual(prolongation_post_response.status, '201 Created')

    prolongation_data = prolongation_post_response.json.get('data', {})
    created_prolongation = Prolongation(prolongation_data)
    created_prolongation.validate()  # check returned data
    test_case.assertEqual(created_prolongation.decisionID,
                          PROLONGATION['decisionID'],
                          'Prolongation creation is wrong.')
    setattr(test_case, test_case_attr, created_prolongation.id)