Beispiel #1
0
def _block_user(session, user_id):
    params = {'id': user_id}
    url = get_url(pages.UpdateUserProfileDetailsPage.url_path)
    r = session.get(url, params=params)

    payload = {'_csrf': get_csrf_token(r)}
    url = get_url(URL_PREFIXES['block_user'])
    r = session.post(url, params=params, data=payload)
    assert_equal(r.status_code, 200)
    assert_in('User has been blocked', r.text)
Beispiel #2
0
def _update_user_record(session, user_id, user_data):
    params = {'id': user_id}
    url = get_url(pages.UpdateUserProfileDetailsPage.url_path)
    r = session.get(url, params=params)

    payload = {
        '_csrf': get_csrf_token(r),
        'Profile[name]': user_data['name'],
        'Profile[public_email]': user_data['public_email'],
        'Profile[location]': user_data['location'],
        'Profile[bio]': user_data['bio'],
        'Profile[partner_id]': user_data['partner_id'],
    }
    r = session.post(url, params=params, data=payload)
    assert_equal(r.status_code, 200)
Beispiel #3
0
def _create_user_record(session, user_data):
    url = get_url(pages.CreateUserPage.url_path)
    r = session.get(url)

    payload = {
        '_csrf': get_csrf_token(r),
        'User[username]': user_data['username'],
        'User[email]': user_data['email'],
        'User[password]': user_data['password'],
    }
    r = session.post(url, data=payload)
    assert_equal(r.status_code, 200)
    assert_in('User has been created', r.text)
    user_id = r.url.split('?id=')[-1]
    return {'id': user_id, 'data_key': user_id}
Beispiel #4
0
def delete_user(user_id):
    s = get_admin_session()
    params = {'id': user_id}
    r = s.get(get_url(pages.UpdateUserProfileDetailsPage.url_path), params=params)

    if 'The requested page does not exist' in r.text:
        assert_equal(r.status_code, 404)
        return

    if 'Access denied' in r.text:
        assert_equal(r.status_code, 403)
        return

    payload = {'_csrf': get_csrf_token(r)}
    url = ''.join([APP_URL, '/user/admin/delete?id={}'.format(user_id)])
    r = s.post(url, data=payload)
    assert_equal(r.status_code, 200)
    assert_in('User has been deleted', r.text)
def create_inventory_group(inventory_group_data):
    payload = {
        'InventoryGroup[name]': inventory_group_data['name'],
        'InventoryGroup[slug]': inventory_group_data['slug'],
        'InventoryGroup[partner_id]': inventory_group_data['partner_id'],
        'InventoryGroup[content]': inventory_group_data['content'],
    }
    s = get_admin_session()
    url = get_url(pages.ManageInventorygroupsPage.url_path + '?sort=-id')
    s.get(url)
    url = get_url(URL_PREFIXES['create_source'].format(name=SOURCE_NAMES_MAP['inventory_group']))
    r = s.get(url)
    data_key = _get_group_data_key(r)
    assert_equal(r.status_code, 200)
    payload['_csrf'] = get_csrf_token(r, on_form=True)
    payload['InventoryGroup[id]'] = data_key
    r = s.post(url, data=payload)
    assert_equal(r.status_code, 200)
    url = get_url(pages.ManageInventorygroupsPage.url_path + '?sort=-id')
    r = s.get(url)
    assert_in(inventory_group_data['name'], r.text)
    _id = _get_group_id(r, data_key)
    return {'id': _id, 'data_key': data_key}