Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions probe_scraper/probe_expiry_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ def check_bugzilla_user_exists(email: str, api_key: str):
try:
user_response.raise_for_status()
except requests.exceptions.HTTPError as e:
# 400 is raised if user does not exist
if e.response.status_code == 400 and e.response.json()["code"] == 51:
# Error code 51 means the user does not exist. Bugzilla used to return
# it with HTTP 400 and now returns it with HTTP 404.
if e.response.status_code in (400, 404) and e.response.json()["code"] == 51:
return False
raise
# As of Sept 2020, api seems to be returning 200 response with an unknown
Expand Down
6 changes: 4 additions & 2 deletions tests/test_probe_expiry_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import dataclass
from unittest import mock

import pytest
from requests.exceptions import HTTPError

from probe_scraper import probe_expiry_alert
Expand Down Expand Up @@ -493,10 +494,11 @@ def test_get_longest_prefix():
assert probe_expiry_alert.get_longest_prefix(["abc"]) == "abc"


@pytest.mark.parametrize("status_code", [400, 404])
@mock.patch("requests.get")
def test_check_bugzilla_user_account_not_found(mock_get):
def test_check_bugzilla_user_account_not_found(mock_get, status_code):
mock_response = mock.MagicMock()
mock_response.status_code = 400
mock_response.status_code = status_code
mock_response.json = mock.MagicMock(return_value={"code": 51})

def user_not_found():
Expand Down