예제 #1
0
def test_find_by_document_id_invalid(session):
    """Assert that the find draft statement by invalid document returns the expected result."""
    with pytest.raises(BusinessException) as not_found_err:
        Draft.find_by_document_number('X12345X', False)

    # check
    assert not_found_err
    assert not_found_err.value.status_code == HTTPStatus.NOT_FOUND
예제 #2
0
def test_find_by_document_id_amendment(session):
    """Assert that the find draft amendment statement by document id contains all expected elements."""
    draft = Draft.find_by_document_number('D-T-AM01', True)
    assert draft
    json_data = draft.json
    assert json_data['amendmentStatement']
    assert json_data['type'] == 'AMENDMENT_STATEMENT'
    assert json_data['amendmentStatement']['registeringParty']
    assert json_data['amendmentStatement']['baseRegistrationNumber']
    assert json_data['amendmentStatement']['changeType']
예제 #3
0
def test_find_by_document_id_financing(session):
    """Assert that the find draft financing statement by document id contains all expected elements."""
    draft = Draft.find_by_document_number('D-T-FS01', True)
    assert draft
    json_data = draft.json
    assert json_data['financingStatement']
    assert json_data['type'] == 'FINANCING_STATEMENT'
    assert json_data['financingStatement']['securedParties'][0]
    assert json_data['financingStatement']['debtors'][0]
    assert json_data['financingStatement']['vehicleCollateral'][0]
    assert json_data['financingStatement']['lifeYears']
예제 #4
0
    def get(document_id):
        """Get a draft statement by document ID."""
        try:
            if document_id is None:
                return path_param_error_response('document ID')

            # Quick check: must be staff or provide an account ID.
            account_id = get_account_id(request)
            if not is_staff(jwt) and account_id is None:
                return account_required_response()

            # Verify request JWT and account ID
            if not authorized(account_id, jwt):
                return unauthorized_error_response(account_id)

            # Try to fetch draft statement by document ID
            draft = Draft.find_by_document_number(document_id, False)

            return draft.json, HTTPStatus.OK

        except BusinessException as exception:
            return business_exception_response(exception)
        except Exception as default_exception:  # noqa: B902; return nicer default error
            return default_exception_response(default_exception)