Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixes #1090 - Removing a point value from bugzilla should set jira's point value to 0 #1091

Merged
merged 1 commit into from
Jan 17, 2025
Merged
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
Fixes #1090 - Removing a point value from bugzilla should set jira's …
…point value to 0
  • Loading branch information
alexcottner committed Jan 16, 2025
commit d2f94a553b63325e42a63593dba0727109bb79fd
1 change: 1 addition & 0 deletions jbi/models.py
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ class ActionParams(BaseModel, frozen=True):
"S4": "S4",
}
cf_fx_points_map: dict[str, int] = {
"---": 0,
"": 0,
"?": 0,
"1": 1,
2 changes: 1 addition & 1 deletion jbi/queue.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 6 additions & 6 deletions tests/unit/test_retry.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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,
31 changes: 31 additions & 0 deletions tests/unit/test_steps.py
Original file line number Diff line number Diff line change
@@ -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,
Loading