Skip to content

Commit 576cd21

Browse files
committed
Explain why we set return value of getbug
1 parent 7f93aeb commit 576cd21

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

jbi/actions/default.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def __call__( # pylint: disable=inconsistent-return-statements
7474

7575
def comment_create_or_noop(self, payload: BugzillaWebhookRequest) -> ActionResult:
7676
"""Confirm issue is already linked, then apply comments; otherwise noop"""
77-
assert payload.bug # make pylint happy. See #219
7877
bug_obj = payload.bug
7978
linked_issue_key = bug_obj.extract_from_see_also()
8079

@@ -145,7 +144,6 @@ def bug_create_or_update(
145144
self, payload: BugzillaWebhookRequest
146145
) -> ActionResult: # pylint: disable=too-many-locals
147146
"""Create and link jira issue with bug, or update; rollback if multiple events fire"""
148-
assert payload.bug # make pylint happy. See #219
149147
bug_obj = payload.bug
150148
linked_issue_key = bug_obj.extract_from_see_also() # type: ignore
151149
if not linked_issue_key:
@@ -241,6 +239,7 @@ def create_and_link_issue( # pylint: disable=too-many-locals
241239
# In the time taken to create the Jira issue the bug may have been updated so
242240
# re-retrieve it to ensure we have the latest data.
243241
bug_obj = self.bugzilla_client.getbug(payload.bug.id)
242+
244243
jira_key_in_bugzilla = bug_obj.extract_from_see_also()
245244
_duplicate_creation_event = (
246245
jira_key_in_bugzilla is not None

jbi/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def execute_action(
4545
raise IgnoreInvalidRequestError(
4646
"bug not accessible or bugzilla down"
4747
) from err
48-
assert request.bug # make pylint happy. See #219
48+
4949
log_context = log_context.update(bug=request.bug)
5050
try:
5151
action = request.bug.lookup_action(actions)

tests/unit/actions/test_default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def test_default_returns_callable_without_data(mocked_bugzilla, mocked_jira):
2929
def test_default_returns_callable_with_data(
3030
webhook_create_example, mocked_jira, mocked_bugzilla
3131
):
32+
mocked_bugzilla.getbug.return_value = webhook_create_example.bug
3233
sentinel = mock.sentinel
3334
mocked_jira.create_or_update_issue_remote_links.return_value = sentinel
34-
mocked_bugzilla.getbug.return_value = webhook_create_example.bug
3535
callable_object = default.init(jira_project_key="")
3636

3737
handled, details = callable_object(payload=webhook_create_example)

tests/unit/actions/test_default_with_assignee_and_status.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def test_create_with_no_assignee(webhook_create_example, mocked_jira, mocked_bug
2626

2727
def test_create_with_assignee(webhook_create_example, mocked_jira, mocked_bugzilla):
2828
webhook_create_example.bug.assigned_to = "[email protected]"
29+
# Make sure the bug fetched the second time in `create_and_link_issue()` also has the assignee.
2930
mocked_bugzilla.getbug.return_value = webhook_create_example.bug
3031
mocked_jira.create_issue.return_value = {"key": "JBI-534"}
3132
mocked_jira.user_find_by_user_string.return_value = [{"accountId": "6254"}]
@@ -148,13 +149,12 @@ def test_create_with_unknown_status(
148149
def test_create_with_known_status(webhook_create_example, mocked_jira, mocked_bugzilla):
149150
webhook_create_example.bug.status = "ASSIGNED"
150151
webhook_create_example.bug.resolution = ""
151-
152-
mocked_jira.create_issue.return_value = {"key": "JBI-534"}
153-
152+
# Make sure the bug fetched the second time in `create_and_link_issue()` also has the status.
154153
mocked_bugzilla.getbug.return_value = webhook_create_example.bug
155154
mocked_bugzilla.get_comments.return_value = {
156155
"bugs": {"654321": {"comments": [{"text": "Initial comment"}]}}
157156
}
157+
mocked_jira.create_issue.return_value = {"key": "JBI-534"}
158158

159159
callable_object = action.init(
160160
jira_project_key="JBI",

0 commit comments

Comments
 (0)