How to use the locustio.common_utils.fetch_by_re function in locustio

To help you get started, we’ve selected a few locustio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
def view_board(locust, board_id, view_backlog=False):
    params = ViewBoard()
    if view_backlog:
        url = f'/secure/RapidBoard.jspa?rapidView={board_id}&view=planning'
    else:
        url = f'/secure/RapidBoard.jspa?rapidView={board_id}'

    r = locust.client.get(url, catch_response=True)
    content = r.content.decode('utf-8')
    project_key = fetch_by_re(params.project_key_pattern, content)
    project_id = fetch_by_re(params.project_id_pattern, content)
    project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2)
    if project_plan:
        project_plan = project_plan.replace('\\', '')
    logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}")
    assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board'

    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1000"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1005"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1010"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1015"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1020"),
                       TEXT_HEADERS, catch_response=True)
github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
def create_issue_open_quick_create():
        r = locust.client.post('/secure/QuickCreateIssue!default.jspa?decorator=none',
                               ADMIN_HEADERS, catch_response=True)
        content = r.content.decode('utf-8')
        atl_token = fetch_by_re(params.atl_token_pattern, content)
        form_token = fetch_by_re(params.form_token_pattern, content)
        issue_type = fetch_by_re(params.issue_type_pattern, content)
        resolution_done = fetch_by_re(params.resolution_done_pattern, content)
        fields_to_retain = re.findall(params.fields_to_retain_pattern, content)
        custom_fields_to_retain = re.findall(params.custom_fields_to_retain_pattern, content)

        issue_body_params_dict = {'atl_token': atl_token,
                                  'form_token': form_token,
                                  'issue_type': issue_type,
                                  'project_id': project_id,
                                  'resolution_done': resolution_done,
                                  'fields_to_retain': fields_to_retain,
                                  'custom_fields_to_retain': custom_fields_to_retain
                                  }
        if not ('"id":"project","label":"Project"' in content):
            logger.error(f'{params.err_message_create_issue}: {content}')
        assert '"id":"project","label":"Project"' in content, params.err_message_create_issue
        locust.client.post('/rest/quickedit/1.0/userpreferences/create', params.user_preferences_payload,
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def create_blog_editor():
        r = locust.client.get(f'/pages/createblogpost.action?spaceKey={blog_space_key}', catch_response=True)
        content = r.content.decode('utf-8')
        if 'Blog post title' not in content:
            logger.error(f'Could not open editor for {blog_space_key}: {content}')
        assert 'Blog post title' in content, 'Could not open editor for blog.'

        atl_token = fetch_by_re(params.atl_token_re, content)
        content_id = fetch_by_re(params.content_id_re, content)
        parsed_space_key = fetch_by_re(params.space_key, content)

        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("910"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.get('/rest/mywork/latest/status/notification/count?pageId=0', catch_response=True)
        locust.client.get('/plugins/servlet/notifications-miniview', catch_response=True)
        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("925"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("930"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.get(f'/rest/emoticons/1.0/_={timestamp_int()}', catch_response=True)
        locust.client.get(f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}?_={timestamp_int()}',
                          catch_response=True)

        heartbeat_activity_body = {"dataType": "json",
                                   "contentId": content_id,
github atlassian / dc-app-performance-toolkit / app / locustio / jira / http_actions.py View on Github external
def view_board(locust, board_id, view_backlog=False):
    params = ViewBoard()
    if view_backlog:
        url = f'/secure/RapidBoard.jspa?rapidView={board_id}&view=planning'
    else:
        url = f'/secure/RapidBoard.jspa?rapidView={board_id}'

    r = locust.client.get(url, catch_response=True)
    content = r.content.decode('utf-8')
    project_key = fetch_by_re(params.project_key_pattern, content)
    project_id = fetch_by_re(params.project_id_pattern, content)
    project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2)
    if project_plan:
        project_plan = project_plan.replace('\\', '')
    logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}")
    assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board'

    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1000"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1005"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1010"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1015"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("1020"),
                       TEXT_HEADERS, catch_response=True)
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def view_page():
        r = locust.client.get(f'/pages/viewpage.action?pageId={page_id}', catch_response=True)
        content = r.content.decode('utf-8')
        if 'Created by' not in content or 'Save for later' not in content:
            logger.error(f'Fail to open page {page_id}: {content}')
        assert 'Created by' in content and 'Save for later' in content, 'Could not open page.'
        parent_page_id = fetch_by_re(params.parent_page_id_re, content)
        parsed_page_id = fetch_by_re(params.page_id_re, content)
        space_key = fetch_by_re(params.space_key_re, content)
        tree_request_id = fetch_by_re(params.tree_result_id_re, content)
        has_no_root = fetch_by_re(params.has_no_root_re, content)
        root_page_id = fetch_by_re(params.root_page_id_re, content)
        atl_token_view_issue = fetch_by_re(params.atl_token_view_issue_re, content)
        editable = fetch_by_re(params.editable_re, content)
        ancestor_ids = re.findall(params.ancestor_ids_re, content)

        ancestor_str = 'ancestors='
        for ancestor in ancestor_ids:
            ancestor_str = ancestor_str + str(ancestor) + '&'

        locust.storage['page_id'] = parsed_page_id
        locust.storage['has_no_root'] = has_no_root
        locust.storage['tree_request_id'] = tree_request_id
        locust.storage['root_page_id'] = root_page_id
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def view_blog(locust):
    params = ViewBlog()
    blog = random.choice(confluence_dataset["blogs"])
    blog_id = blog[0]

    r = locust.client.get(f'/pages/viewpage.action?pageId={blog_id}', catch_response=True)
    content = r.content.decode('utf-8')
    if 'Created by' not in content or 'Save for later' not in content:
        logger.error(f'Fail to open blog {blog_id}: {content}')
    assert 'Created by' in content and 'Save for later' in content, 'Could not view blog.'

    parent_page_id = fetch_by_re(params.parent_page_id_re, content)
    parsed_blog_id = fetch_by_re(params.page_id_re, content)
    space_key = fetch_by_re(params.space_key_re, content)

    locust.client.get('/rest/helptips/1.0/tips', catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("310"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.get(f'/rest/likes/1.0/content/{parsed_blog_id}/likes?commentLikes=true&_={timestamp_int()}',
                      catch_response=True)
    locust.client.get(f'/rest/highlighting/1.0/panel-items?pageId={parsed_blog_id}&_={timestamp_int()}',
                      catch_response=True)
    locust.client.get(f'/rest/mywork/latest/status/notification/count?pageId={parsed_blog_id}&_={timestamp_int()}',
                      catch_response=True)
    r = locust.client.get(f'/rest/inlinecomments/1.0/comments?containerId={parsed_blog_id}&_={timestamp_int()}',
                          catch_response=True)
    content = r.content.decode('utf-8')
    if 'authorDisplayName' not in content and '[]' not in content:
        logger.error(f'Could not open comments for page {parsed_blog_id}: {content}')
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def view_page():
        r = locust.client.get(f'/pages/viewpage.action?pageId={page_id}', catch_response=True)
        content = r.content.decode('utf-8')
        if 'Created by' not in content or 'Save for later' not in content:
            logger.error(f'Fail to open page {page_id}: {content}')
        assert 'Created by' in content and 'Save for later' in content, 'Could not open page.'
        parent_page_id = fetch_by_re(params.parent_page_id_re, content)
        parsed_page_id = fetch_by_re(params.page_id_re, content)
        space_key = fetch_by_re(params.space_key_re, content)
        tree_request_id = fetch_by_re(params.tree_result_id_re, content)
        has_no_root = fetch_by_re(params.has_no_root_re, content)
        root_page_id = fetch_by_re(params.root_page_id_re, content)
        atl_token_view_issue = fetch_by_re(params.atl_token_view_issue_re, content)
        editable = fetch_by_re(params.editable_re, content)
        ancestor_ids = re.findall(params.ancestor_ids_re, content)

        ancestor_str = 'ancestors='
        for ancestor in ancestor_ids:
            ancestor_str = ancestor_str + str(ancestor) + '&'

        locust.storage['page_id'] = parsed_page_id
        locust.storage['has_no_root'] = has_no_root
        locust.storage['tree_request_id'] = tree_request_id
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def create_blog_editor():
        r = locust.client.get(f'/pages/createblogpost.action?spaceKey={blog_space_key}', catch_response=True)
        content = r.content.decode('utf-8')
        if 'Blog post title' not in content:
            logger.error(f'Could not open editor for {blog_space_key}: {content}')
        assert 'Blog post title' in content, 'Could not open editor for blog.'

        atl_token = fetch_by_re(params.atl_token_re, content)
        content_id = fetch_by_re(params.content_id_re, content)
        parsed_space_key = fetch_by_re(params.space_key, content)

        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("910"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.get('/rest/mywork/latest/status/notification/count?pageId=0', catch_response=True)
        locust.client.get('/plugins/servlet/notifications-miniview', catch_response=True)
        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("925"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("930"),
                           TEXT_HEADERS, catch_response=True)
        locust.client.get(f'/rest/emoticons/1.0/_={timestamp_int()}', catch_response=True)
        locust.client.get(f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}?_={timestamp_int()}',
                          catch_response=True)

        heartbeat_activity_body = {"dataType": "json",
                                   "contentId": content_id,
                                   "draftType": "blogpost",
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def open_editor():
        create_page_id = locust.storage['create_page_id']

        r = locust.client.get(f'/pages/editpage.action?pageId={create_page_id}', catch_response=True)
        content = r.content.decode('utf-8')
        if '<title>Edit' not in content or 'Update&lt;/button&gt;' not in content:
            logger.error(f'Could not open PAGE {create_page_id} to edit: {content}')
        assert '&lt;title&gt;Edit' in content and 'Update&lt;/button&gt;' in content, \
               'Could not open PAGE to edit.'

        edit_page_version = fetch_by_re(params.editor_page_version_re, content)
        edit_atl_token = fetch_by_re(params.atl_token_re, content)
        edit_space_key = fetch_by_re(params.space_key_re, content)
        edit_content_id = fetch_by_re(params.content_id_re, content)
        edit_page_id = fetch_by_re(params.page_id_re, content)
        edit_parent_page_id = fetch_by_re(params.parent_page_id, content)

        locust.storage['edit_parent_page_id'] = edit_parent_page_id
        locust.storage['edit_page_version'] = edit_page_version
        locust.storage['edit_page_id'] = edit_page_id
        locust.storage['atl_token'] = edit_atl_token
        locust.storage['edit_content_id'] = edit_content_id

        locust.client.get(f'/rest/jiraanywhere/1.0/servers?_={timestamp_int()}', catch_response=True)
        heartbeat_activity_body = {"dataType": "json",
                                   "contentId": edit_content_id,
                                   "draftType": "page",</title>
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def view_blog(locust):
    params = ViewBlog()
    blog = random.choice(confluence_dataset["blogs"])
    blog_id = blog[0]

    r = locust.client.get(f'/pages/viewpage.action?pageId={blog_id}', catch_response=True)
    content = r.content.decode('utf-8')
    if 'Created by' not in content or 'Save for later' not in content:
        logger.error(f'Fail to open blog {blog_id}: {content}')
    assert 'Created by' in content and 'Save for later' in content, 'Could not view blog.'

    parent_page_id = fetch_by_re(params.parent_page_id_re, content)
    parsed_blog_id = fetch_by_re(params.page_id_re, content)
    space_key = fetch_by_re(params.space_key_re, content)

    locust.client.get('/rest/helptips/1.0/tips', catch_response=True)
    locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("310"),
                       TEXT_HEADERS, catch_response=True)
    locust.client.get(f'/rest/likes/1.0/content/{parsed_blog_id}/likes?commentLikes=true&_={timestamp_int()}',
                      catch_response=True)
    locust.client.get(f'/rest/highlighting/1.0/panel-items?pageId={parsed_blog_id}&_={timestamp_int()}',
                      catch_response=True)
    locust.client.get(f'/rest/mywork/latest/status/notification/count?pageId={parsed_blog_id}&_={timestamp_int()}',
                      catch_response=True)
    r = locust.client.get(f'/rest/inlinecomments/1.0/comments?containerId={parsed_blog_id}&_={timestamp_int()}',
                          catch_response=True)
    content = r.content.decode('utf-8')
    if 'authorDisplayName' not in content and '[]' not in content: