def test__get_avg_viewers_in_past_week_gt_400_status_code_throws_exception(): responses.add(responses.GET, f'{BASE_TWITCHMETRICS_URL}/c/{example_users_list[0]["_id"]}-' f'{example_users_list[0]["name"]}/recent_viewership_values', status=400, content_type='text/html') getter = ClipGetter(example_users_list) with pytest.raises(requests.HTTPError): getter._get_avg_viewers_in_past_week(example_users_list[0]['_id'], example_users_list[0]['name'])
def test__get_avg_viewers_in_past_week_cant_find_user_ret_0(): expected_avg = 0 responses.add(responses.GET, f'{BASE_TWITCHMETRICS_URL}/c/{example_users_list[0]["_id"]}-' f'{example_users_list[0]["name"]}/recent_viewership_values', status=404, content_type='text/html') getter = ClipGetter(example_users_list) avg = getter._get_avg_viewers_in_past_week(example_users_list[0]['_id'], example_users_list[0]['name']) assert expected_avg == avg
def test__get_avg_viewers_in_past_week_user_didnt_stream_ret_0(): expected_avg = 0 responses.add(responses.GET, f'{BASE_TWITCHMETRICS_URL}/c/{example_users_list[0]["_id"]}-' f'{example_users_list[0]["name"]}/recent_viewership_values', body=json.dumps(example_twitchmetrics_viewership_resp_empty), status=200, content_type='application/json') getter = ClipGetter(example_users_list) avg = getter._get_avg_viewers_in_past_week(example_users_list[0]['_id'], example_users_list[0]['name']) assert expected_avg == avg