def METHOD_NAME(app, login, data, version_of=None):
    """Create a record."""
    # TODO: replace this with the create_record helper. We don't need to create
    # the record via the REST API for this test.
    with app.test_client() as client:
        # Create the record draft
        login.owner(client)
        url = url_for('b2share_records_rest.b2rec_list')
        if version_of:
            url += "?version_of="+version_of['id']
        res = client.post(url, data=json.dumps(data), headers=headers)
        res_json = json.loads(res.get_data(as_text=True))
        assert res.status_code == 201
        if version_of:
            assert 'versions' in res_json['links']
        draft_url = res_json['links']['self']
    # submits the record
    with app.test_client() as client:
        login.owner(client)
        patch = [{
            "op": "replace", "path": "/publication_state",
            "value": PublicationStates.submitted.name,
        }]
        res = client.patch(draft_url, data=json.dumps(patch), headers=patch_headers)
        assert 200 <= res.status_code <= 201
    # publish the record
    with app.test_client() as client:
        login.admin(client)
        patch[0]['value'] = PublicationStates.published.name
        res = client.patch(draft_url, data=json.dumps(patch), headers=patch_headers)
        assert 200 <= res.status_code <= 201
        deposit_json_data = json.loads(res.get_data(as_text=True))
        if version_of:
            assert 'versions' in deposit_json_data['links']
    # Test retrieving the record
    url = url_for('b2share_records_rest.b2rec_item', pid_value=deposit_json_data['id'])
    with app.test_client() as client:
        login.normal(client)
        res = client.get(url, headers=headers)
        assert res.status_code == 200
        res_json = json.loads(res.get_data(as_text=True))
        if version_of:
            assert 'versions' in res_json['links']
        return res_json