Skip to content

Commit 7f93aeb

Browse files
committed
Merge remote-tracking branch 'origin/main' into refactor-model-services
2 parents 4f5d6a8 + 3c2c5dd commit 7f93aeb

File tree

6 files changed

+19
-25
lines changed

6 files changed

+19
-25
lines changed

jbi/actions/default.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,13 @@ def create_and_link_issue( # pylint: disable=too-many-locals
275275
jira_key_in_response,
276276
extra=log_context.update(operation=Operation.LINK).dict(),
277277
)
278+
icon_url = f"{settings.bugzilla_base_url}/favicon.ico"
278279
jira_response = self.jira_client.create_or_update_issue_remote_links(
279280
issue_key=jira_key_in_response,
280281
link_url=bugzilla_url,
281-
title=f"Bugzilla Bug {bug_obj.id}",
282+
title=bugzilla_url,
283+
icon_url=icon_url,
284+
icon_title=icon_url,
282285
)
283286

284287
self.update_issue(payload, bug_obj, jira_key_in_response, is_new=True)

jbi/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class Config:
325325
webhook_id: int
326326
webhook_name: str
327327
event: BugzillaWebhookEvent
328-
bug: Optional[BugzillaBug]
328+
bug: BugzillaBug
329329

330330
def map_as_jira_comment(self):
331331
"""Extract comment from Webhook Event"""

jbi/runner.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,15 @@ def execute_action(
2828
The value returned by the action call is returned.
2929
"""
3030
log_context = RunnerLogContext(
31-
bug={
32-
"id": request.bug.id if request.bug else None,
33-
},
34-
request=request,
31+
bug=request.bug.dict(),
32+
request=request.dict(),
3533
operation=Operation.HANDLE,
3634
)
3735
try:
3836
logger.debug(
3937
"Handling incoming request",
4038
extra=log_context.dict(),
4139
)
42-
if not request.bug:
43-
raise IgnoreInvalidRequestError("no bug data received")
4440

4541
try:
4642
request = request.copy(update={"bug": bugzilla_fetch_private(request.bug)})

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fastapi = "^0.79.0"
1111
pydantic = {version = "^1.9.2", extras = ["dotenv", "email"]}
1212
uvicorn = {extras = ["standard"], version = "^0.18.2"}
1313
python-bugzilla = "^3.2.0"
14-
atlassian-python-api = { git = "https://github.com/atlassian-api/atlassian-python-api.git", rev = "82293a2ac9bfa" }
14+
atlassian-python-api = { git = "https://github.com/atlassian-api/atlassian-python-api.git", rev = "4e8698863e4d2" }
1515
dockerflow = "2022.7.0"
1616
Jinja2 = "^3.1.2"
1717
pydantic-yaml = {extras = ["pyyaml","ruamel"], version = "^0.8.0"}

tests/unit/test_router.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ def test_webhook_is_200_if_action_raises_IgnoreInvalidRequestError(
111111
)
112112

113113

114+
def test_webhook_is_422_if_bug_information_missing(webhook_create_example):
115+
webhook_create_example.bug = None
116+
117+
with TestClient(app) as anon_client:
118+
response = anon_client.post(
119+
"/bugzilla_webhook", data=webhook_create_example.json()
120+
)
121+
assert response.status_code == 422
122+
assert response.json()["detail"][0]["msg"] == "none is not an allowed value"
123+
124+
114125
def test_read_version(anon_client):
115126
"""__version__ returns the contents of version.json."""
116127
here = os.path.dirname(__file__)

tests/unit/test_runner.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,6 @@ def test_private_request_is_allowed(
5656
assert payload.bug.id == 654321
5757

5858

59-
def test_request_is_ignored_because_no_bug(
60-
webhook_create_example: BugzillaWebhookRequest,
61-
actions_example: Actions,
62-
settings: Settings,
63-
):
64-
webhook_create_example.bug = None
65-
66-
with pytest.raises(IgnoreInvalidRequestError) as exc_info:
67-
execute_action(
68-
request=webhook_create_example,
69-
actions=actions_example,
70-
settings=settings,
71-
)
72-
assert str(exc_info.value) == "no bug data received"
73-
74-
7559
def test_request_is_ignored_because_no_action(
7660
webhook_create_example: BugzillaWebhookRequest,
7761
actions_example: Actions,

0 commit comments

Comments
 (0)