예제 #1
0
def get_enabled_partners_data_keys():
    s = get_admin_session()
    url = get_url(pages.ManagePartnersPage.url_path)
    r = s.get(url)
    soup = BeautifulSoup(r.text)
    partners = soup.findAll(lambda tag: 'data-key' in tag.attrs and 'Enabled' in tag.text)
    partners_ids = [p['data-key'] for p in partners]
    return partners_ids
예제 #2
0
def get_published_parent_pages_ids():
    s = get_admin_session()
    url = get_url(pages.ManagePagesPage.url_path)
    r = s.get(url)
    soup = BeautifulSoup(r.text)
    pages_published = soup.findAll(lambda tag: 'data-key' in tag.attrs and 'Published' in tag.text)
    pages_parent = list(filter(lambda x: 'glyphicon-paperclip' not in str(x), pages_published))
    pages_parent_ids = [p['data-key'] for p in pages_parent]
    return pages_parent_ids
예제 #3
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)
예제 #4
0
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}
예제 #5
0
def create_blocked_user(user_data):
    s = get_admin_session()
    user_info = _create_user_record(s, user_data)
    _update_user_record(s, user_info.get('id'), user_data)
    _block_user(s, user_info.get('id'))
    return user_info