Skip to content

Commit

Permalink
Fixes mozilla#1090 - Removing a point value from bugzilla should set …
Browse files Browse the repository at this point in the history
…jira's point value to 0 (mozilla#1091)
  • Loading branch information
alexcottner authored and davehunt committed Jan 29, 2025
1 parent 032f609 commit 5c36850
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions jbi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class ActionParams(BaseModel, frozen=True):
"S4": "S4",
}
cf_fx_points_map: dict[str, int] = {
"---": 0,
"": 0,
"?": 0,
"1": 1,
Expand Down
2 changes: 1 addition & 1 deletion jbi/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def timestamp(self) -> datetime:
@computed_field # type: ignore
@property
def identifier(self) -> str:
return f"{self.payload.event.time}-{self.payload.bug.id}-{self.payload.event.action}-{"error" if self.error else "postponed"}"
return f"{self.payload.event.time}-{self.payload.bug.id}-{self.payload.event.action}-{'error' if self.error else 'postponed'}"


@lru_cache(maxsize=1)
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ async def test_retry_remove_expired(

metrics = await retry_failed(item_executor=mock_executor, queue=mock_queue)
mock_queue.retrieve.assert_called_once()
assert (
len(mock_queue.done.call_args_list) == 2
), "both items should have been marked as done"
assert len(mock_queue.done.call_args_list) == 2, (
"both items should have been marked as done"
)
assert caplog.text.count("failed to reprocess event") == 0
assert caplog.text.count("removing expired event") == 1
mock_executor.assert_called_once() # only one item should have been attempted to be processed
Expand All @@ -140,9 +140,9 @@ async def test_retry_remove_invalid(
mock.DEFAULT,
]
metrics = await retry_failed(item_executor=mock_executor, queue=mock_queue)
assert (
len(mock_queue.done.call_args_list) == 2
), "both items should have been marked as done"
assert len(mock_queue.done.call_args_list) == 2, (
"both items should have been marked as done"
)
assert caplog.text.count("removing invalid event") == 1
assert metrics == {
"bug_count": 1,
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,37 @@ def test_update_issue_points(
)


def test_update_issue_points_removed(
action_context_factory,
mocked_jira,
action_params_factory,
webhook_event_change_factory,
):
action_context = action_context_factory(
operation=Operation.UPDATE,
current_step="maybe_update_issue_points",
bug__see_also=["https://mozilla.atlassian.net/browse/JBI-234"],
jira__issue="JBI-234",
bug__cf_fx_points="---",
event__action="modify",
event__changes=[
webhook_event_change_factory(field="cf_fx_points", removed="?", added="0")
],
)

params = action_params_factory(
jira_project_key=action_context.jira.project,
)
steps.maybe_update_issue_points(
action_context, parameters=params, jira_service=JiraService(mocked_jira)
)

mocked_jira.create_issue.assert_not_called()
mocked_jira.update_issue_field.assert_called_with(
key="JBI-234", fields={"customfield_10037": 0}
)


def test_update_issue_points_missing_in_map(
action_context_factory,
mocked_jira,
Expand Down

0 comments on commit 5c36850

Please # to comment.