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']
    )
def upload_document(test_case):
    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))
    prolongation_before_document_post = Prolongation(
        prolongation_response.json['data'])
    test_case.assertEqual(prolongation_before_document_post.documents, [])

    add_document_response = test_case.app.post(
        PATHS['prolongation_documents'].format(
            auction_id=test_case.auction_id,
            contract_id=test_case.contract_id,
            prolongation_id=test_case.prolongation_id,
            token=test_case.auction_token),
        upload_files=[
            ('file', 'ProlongationDocument.doc',
             'content_with_prolongation_data'),
        ])
    test_case.assertEqual(add_document_response.status, '201 Created')
    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))
    prolongation_after_document_post = Prolongation(
        prolongation_response.json['data'])
    test_case.assertNotEqual(prolongation_after_document_post.documents, [])
    test_case.assertEqual(add_document_response.status, '201 Created')
Exemplo n.º 3
0
def upload_document(test_case):
    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))
    prolongation_before_document_post = Prolongation(
        prolongation_response.json['data'])
    test_case.assertEqual(prolongation_before_document_post.documents, [])

    response = test_case.app.post_json(PATHS['prolongation_documents'].format(
        auction_id=test_case.auction_id,
        contract_id=test_case.contract_id,
        prolongation_id=test_case.prolongation_id,
        token=test_case.auction_token), {
            'data': {
                'title': u'ProlongationDocument.doc',
                'url': test_case.generate_docservice_url(),
                'hash': 'md5:' + '0' * 32,
                'format': 'application/pdf',
                "documentType": "wrongDocumentType",
                "description": "content_with_prolongation_data"
            }
        },
                                       status=422)
    test_case.assertEqual(response.status, '422 Unprocessable Entity')
    test_case.assertEqual(
        response.json['errors'],
        [{
            u'description':
            [u"Value must be one of ['prolongationProtocol']."],
            u'location': u'body',
            u'name': u'documentType'
        }])
    add_document_response = test_case.app.post_json(
        PATHS['prolongation_documents'].format(
            auction_id=test_case.auction_id,
            contract_id=test_case.contract_id,
            prolongation_id=test_case.prolongation_id,
            token=test_case.auction_token), {
                'data': {
                    'title': u'ProlongationDocument.doc',
                    'url': test_case.generate_docservice_url(),
                    'hash': 'md5:' + '0' * 32,
                    'format': 'application/pdf',
                    "documentType": "prolongationProtocol",
                    "description": "content_with_prolongation_data"
                }
            })
    test_case.assertEqual(add_document_response.status, '201 Created')
    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))
    prolongation_after_document_post = Prolongation(
        prolongation_response.json['data'])
    test_case.assertNotEqual(prolongation_after_document_post.documents, [])
    test_case.assertEqual(add_document_response.status, '201 Created')
Exemplo n.º 4
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 fixture_created(self):
        contract = Contract(contract_data)
        contract.__parent__ = fixture_auction()
        contract.signingPeriod = Period({
            'startDate': '2000-01-01T10:00:00+02:00',
            'endDate': '2000-01-10T10:00:00+02:00'
        })

        prolongation = Prolongation(self.fixture_required_data())
        contract.prolongations.append(contract)
        prolongation.__parent__ = contract  # mock

        prolongation_doc = self.fixture_document()
        prolongation_doc.__parent__ = prolongation
        prolongation.documents.append(prolongation_doc)
        return (contract, prolongation)
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)