示例#1
0
def test_update_invalid(session):
    """Assert that an update draft statement with a non-existent document id returns the expected result."""
    json_data = copy.deepcopy(DRAFT_CHANGE_STATEMENT)

    with pytest.raises(BusinessException) as not_found_err:
        Draft.update(json_data, 'X12345X')

    # check
    assert not_found_err
    assert not_found_err.value.status_code == HTTPStatus.NOT_FOUND
示例#2
0
    def put(document_id):
        """Update a draft statement by document ID with data in the request body."""
        try:
            if document_id is None:
                return path_param_error_response('document ID')

            # Quick check: must provide an account ID.
            account_id = get_account_id(request)
            if 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)

            request_json = request.get_json(silent=True)
            # Disable schema validation: draft may be partial/incomplele.
            # valid_format, errors = schema_utils.validate(request_json, 'draft', 'ppr')
            # if not valid_format:
            #   return validation_error_response(errors, VAL_ERROR)

            # Save draft statement update: BusinessException raised if failure.
            draft = Draft.update(request_json, document_id)
            draft.save()

            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)
示例#3
0
def test_update(session):
    """Assert that a valid update draft statement returns the expected result."""
    json_data = copy.deepcopy(DRAFT_CHANGE_STATEMENT)
    updated = Draft.update(json_data, 'D-T-CH01')
    updated.save()
    draft = updated.json
    assert draft
    assert draft['changeStatement']
    assert draft['type'] == 'CHANGE_STATEMENT'
    assert draft['createDateTime']
    assert draft['lastUpdateDateTime']
    assert draft['changeStatement']['registeringParty']
    assert draft['changeStatement']['baseRegistrationNumber']
    assert draft['changeStatement']['changeType']
    assert draft['changeStatement']['documentId']