Exemplo n.º 1
0
def test_get_existing_user_settings(client, jwt, app):
    """Test getting user settings for an existing user."""
    user = User(
        username='******',
        sub='43e6a245-0bf7-4ccf-9bd0-e7fb85fd18cc',  # this needs to match the sub in create_header
        firstname='',
        lastname='',
        iss=''
    )
    user.searchColumns = 'Status'
    user.save_to_db()

    # check it gets the existing settings stored in the db
    existing_user_settings = client.get(f'api/v1/usersettings', headers=create_header(jwt, [User.EDITOR], 'test-settings'))
    data = existing_user_settings.data
    assert data
    resp = json.loads(data.decode('utf-8'))

    assert resp.get('searchColumns')
    assert resp.get('searchColumns') == ['Status']
Exemplo n.º 2
0
def test_update_user_settings(client, jwt, app):
    """Test updating user settings for an existing user."""
    # create user with settings
    user = User(
        username='******',
        sub='43e6a245-0bf7-4ccf-9bd0-e7fb85fd18cc',  # this needs to match the sub in create_header
        firstname='',
        lastname='',
        iss=''
    )
    user.searchColumns = 'Status'
    user.save_to_db()
    # update user with put endpoint
    update_user_settings = client.put(
        f'api/v1/usersettings',
        json={ 'searchColumns': ['Status','LastModifiedBy'] },
        headers=create_header(jwt, [User.EDITOR], 'test-settings')
    )
    # assert user was successfully updated
    assert update_user_settings.status_code == 204
    assert user.searchColumns == 'Status,LastModifiedBy'