Пример #1
0
def test_payment_header(session, client, jwt):
    """Assert that a filing can be completed up to payment."""
    from legal_api.models import Filing
    identifier = 'CP7654321'
    payment_account = '12345'
    business = factory_business(identifier,
                                founding_date=(datetime.utcnow() -
                                               datedelta.YEAR))
    factory_business_mailing_address(business)
    data = copy.deepcopy(FILING_HEADER)
    data['filing']['header']['name'] = 'specialResolution'
    data['filing']['specialResolution'] = SPECIAL_RESOLUTION

    rv = client.post(f'/api/v1/businesses/{identifier}/filings',
                     json=data,
                     headers=create_header(jwt, [STAFF_ROLE], identifier,
                                           **{'accountID': payment_account}))
    # check return
    assert rv.status_code == HTTPStatus.CREATED
    assert not rv.json.get('errors')
    assert rv.json['filing']['header']['filingId']

    # check stored filing
    filing = Filing.find_by_id(rv.json['filing']['header']['filingId'])
    assert filing
    assert filing.payment_account == payment_account
Пример #2
0
def test_deleting_filings_deletion_locked(session, client, jwt, legal_type,
                                          deletion_locked, message):
    """Assert that filing cannot be deleted with deletion_locked flag."""
    identifier = 'BC7654321'
    factory_business(identifier, entity_type=legal_type.value)
    headers = create_header(jwt, [STAFF_ROLE], identifier)
    rv = client.post(f'/api/v1/businesses/{identifier}/filings?draft=true',
                     json=ALTERATION_FILING_TEMPLATE,
                     headers=headers)

    assert rv.status_code == HTTPStatus.CREATED
    filing_id = rv.json['filing']['header']['filingId']
    if deletion_locked:
        filing = Filing.find_by_id(filing_id)
        filing.deletion_locked = True
        filing.save()

    rv = client.delete(f'/api/v1/businesses/{identifier}/filings/{filing_id}',
                       headers=headers)
    if deletion_locked:
        assert rv.status_code == HTTPStatus.UNAUTHORIZED
        assert rv.json.get('message') == message
    else:
        assert rv.status_code == HTTPStatus.OK