Example #1
0
def test_invalid_blazemeter_api_url():
    with mock.patch('core.blazemeter.api.BLAZEMETER_API_URL',
                    "http://invalid.com"):
        response = api.bm_api(method="GET",
                              url="/sessions/" + MOCK_SESSION_ID +
                              "/reports/main/summary")
        assert not response
Example #2
0
def get_session_id():
    global MOCK_SESSION_ID
    with mock.patch('core.blazemeter.api.BLAZEMETER_API_URL',
                    "https://a.blazemeter.com/api/v4"):
        response = api.bm_api(method="GET",
                              url="/sessions?projectId=" + PROJECT_ID +
                              "&workspaceId=" + WORKSPACE_ID + "&limit=1")
        MOCK_SESSION_ID = response['result'][0]['id']
Example #3
0
def compare_runs():
    """Gets information on each run_name"""
    old_run, new_runs, csv_output = get_args()
    all_runs = new_runs[:]
    all_runs.append(old_run)

    run_data = collections.defaultdict(dict)
    for run in all_runs:
        run_info = api.bm_api(
            "GET",
            url=
            f'/masters?projectId=PROJECT_ID&workspaceId=WORKSPACE_ID&limit=10&name={run}'
        )
        run_sessions = [
            session for run in run_info.get('result', [])
            for session in run.get('sessionsId', [])
        ]
        run_data[run]['session_ids'] = run_sessions
        if not run_sessions:
            print("Could not find any sessions associated with {run_name}".
                  format(run_name=run))
            exit(1)

    # get session information for all runs
    for run_name in run_data:
        run_data[run_name]['session_data'] = []
        for session_id in run_data[run_name]['session_ids']:
            session = Session(session_id)
            session.get_average_info()
            run_data[run_name]['session_data'].append(session)

        # aggregate session averages
        run_data[run_name][
            'session_averages'] = combine_runs.aggregate_session_averages(
                run_data[run_name]['session_data'])

    avg_comparison = combine_runs.compare_averages(run_data)

    # GENERATE_SUMMARY
    if printer.generate_csv_avg_comparison(avg_comparison, old_run, new_runs,
                                           csv_output):
        exit(0)
    exit(1)
Example #4
0
def test_no_url():
    response = api.bm_api(method="GET")
    assert not response
Example #5
0
def test_valid_url():
    response = api.bm_api(method="GET",
                          url="/sessions/" + MOCK_SESSION_ID +
                          "/reports/main/summary")
    assert response
    assert not response['error']
Example #6
0
def test_invalid_url():
    response = api.bm_api(method="GET", url="/endpoint_does_not_exit")
    assert not response
Example #7
0
 def get_session_data(self):
     session_info = bm_api(
         method="GET",
         url=f'/sessions/{self.session_id}/reports/main/summary')
     if session_info:
         self.session_info = session_info