How to use the locustio.common_utils.JSON_HEADERS 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 / confluence / http_actions.py View on Github external
def like_page(locust):
    params = LikePage()
    page = random.choice(confluence_dataset["pages"])
    page_id = page[0]

    JSON_HEADERS['Origin'] = CONFLUENCE_SETTINGS.server_url
    r = locust.client.get(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
    content = r.content.decode('utf-8')
    like = fetch_by_re(params.like_re, content)

    if like is None:
        r = locust.client.post(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
    else:
        r = locust.client.delete(f'/rest/likes/1.0/content/{page_id}/likes', catch_response=True)

    content = r.content.decode('utf-8')
    if 'likes' not in content:
        logger.error(f"Could not set like to the page {page_id}: {content}")
    assert 'likes' in r.content.decode('utf-8'), 'Could not set like to the page.'
github atlassian / dc-app-performance-toolkit / app / locustio / confluence / http_actions.py View on Github external
def like_page(locust):
    params = LikePage()
    page = random.choice(confluence_dataset["pages"])
    page_id = page[0]

    JSON_HEADERS['Origin'] = CONFLUENCE_SETTINGS.server_url
    r = locust.client.get(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
    content = r.content.decode('utf-8')
    like = fetch_by_re(params.like_re, content)

    if like is None:
        r = locust.client.post(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True)
    else:
        r = locust.client.delete(f'/rest/likes/1.0/content/{page_id}/likes', catch_response=True)

    content = r.content.decode('utf-8')
    if 'likes' not in content:
        logger.error(f"Could not set like to the page {page_id}: {content}")
    assert 'likes' in r.content.decode('utf-8'), 'Could not set like to the page.'