Skip to content

Commit dc91f77

Browse files
authored
Fix #382: retry login requests to Bugzilla (#516)
1 parent e53db57 commit dc91f77

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

jbi/services/bugzilla.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _call(self, verb, url, *args, **kwargs):
5959
raise BugzillaClientError(parsed["message"])
6060
return parsed
6161

62-
@property
62+
@instrumented_method
6363
def logged_in(self) -> bool:
6464
"""Verify the API key validity."""
6565
# https://bugzilla.readthedocs.io/en/latest/api/core/v1/user.html#who-am-i
@@ -137,7 +137,7 @@ def get_client():
137137
def check_health() -> ServiceHealth:
138138
"""Check health for Bugzilla Service"""
139139
client = get_client()
140-
logged_in = client.logged_in
140+
logged_in = client.logged_in()
141141

142142
# Check that all JBI webhooks are enabled in Bugzilla,
143143
# and report disabled ones.

tests/unit/services/test_bugzilla.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_bugzilla_key_is_passed_in_header(mocked_responses):
5252
],
5353
)
5454

55-
assert get_client().logged_in
55+
assert get_client().logged_in()
5656

5757
assert len(mocked_responses.calls) == 1
5858
# The following assertion is redundant with matchers but also more explicit.

tests/unit/test_router.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_read_version(anon_client):
155155

156156
def test_read_heartbeat_all_services_fail(anon_client, mocked_jira, mocked_bugzilla):
157157
"""/__heartbeat__ returns 503 when all the services are unavailable."""
158-
mocked_bugzilla.logged_in = False
158+
mocked_bugzilla.logged_in.return_value = False
159159
mocked_jira.get_server_info.return_value = None
160160

161161
resp = anon_client.get("/__heartbeat__")
@@ -193,7 +193,7 @@ def test_read_heartbeat_jira_services_fails(anon_client, mocked_jira, mocked_bug
193193
def test_read_heartbeat_bugzilla_webhooks_fails(
194194
anon_client, mocked_jira, mocked_bugzilla
195195
):
196-
mocked_bugzilla.logged_in = True
196+
mocked_bugzilla.logged_in.return_value = True
197197
mocked_bugzilla.list_webhooks.return_value = [
198198
EXAMPLE_WEBHOOK.copy(update={"enabled": False})
199199
]
@@ -211,7 +211,7 @@ def test_read_heartbeat_bugzilla_services_fails(
211211
anon_client, mocked_jira, mocked_bugzilla
212212
):
213213
"""/__heartbeat__ returns 503 when one service is unavailable."""
214-
mocked_bugzilla.logged_in = False
214+
mocked_bugzilla.logged_in.return_value = False
215215
mocked_jira.get_server_info.return_value = {}
216216
mocked_jira.projects.return_value = [{"key": "DevTest"}]
217217

@@ -226,7 +226,7 @@ def test_read_heartbeat_bugzilla_services_fails(
226226

227227
def test_read_heartbeat_success(anon_client, mocked_jira, mocked_bugzilla):
228228
"""/__heartbeat__ returns 200 when checks succeed."""
229-
mocked_bugzilla.logged_in = True
229+
mocked_bugzilla.logged_in.return_value = True
230230
mocked_bugzilla.list_webhooks.return_value = [EXAMPLE_WEBHOOK]
231231
mocked_jira.get_server_info.return_value = {}
232232
mocked_jira.projects.return_value = [{"key": "DevTest"}]
@@ -297,7 +297,7 @@ def test_jira_heartbeat_missing_permissions(anon_client, mocked_jira, mocked_bug
297297

298298

299299
def test_jira_heartbeat_unknown_components(anon_client, mocked_jira, mocked_bugzilla):
300-
mocked_bugzilla.logged_in = True
300+
mocked_bugzilla.logged_in.return_value = True
301301
mocked_bugzilla.list_webhooks.return_value = [EXAMPLE_WEBHOOK]
302302
mocked_jira.get_server_info.return_value = {}
303303

@@ -309,7 +309,7 @@ def test_jira_heartbeat_unknown_components(anon_client, mocked_jira, mocked_bugz
309309

310310
def test_head_heartbeat_success(anon_client, mocked_jira, mocked_bugzilla):
311311
"""/__heartbeat__ support head requests"""
312-
mocked_bugzilla.logged_in = True
312+
mocked_bugzilla.logged_in.return_value = True
313313
mocked_bugzilla.list_webhooks.return_value = [EXAMPLE_WEBHOOK]
314314
mocked_jira.get_server_info.return_value = {}
315315
mocked_jira.projects.return_value = [{"key": "DevTest"}]

0 commit comments

Comments
 (0)