Skip to content

Commit a03eed7

Browse files
authored
Fixes #1090 - Removing a point value from bugzilla should set jira's point value to 0 (#1091)
1 parent 5b91645 commit a03eed7

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

jbi/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class ActionParams(BaseModel, frozen=True):
100100
"S4": "S4",
101101
}
102102
cf_fx_points_map: dict[str, int] = {
103+
"---": 0,
103104
"": 0,
104105
"?": 0,
105106
"1": 1,

jbi/queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def timestamp(self) -> datetime:
104104
@computed_field # type: ignore
105105
@property
106106
def identifier(self) -> str:
107-
return f"{self.payload.event.time}-{self.payload.bug.id}-{self.payload.event.action}-{"error" if self.error else "postponed"}"
107+
return f"{self.payload.event.time}-{self.payload.bug.id}-{self.payload.event.action}-{'error' if self.error else 'postponed'}"
108108

109109

110110
@lru_cache(maxsize=1)

tests/unit/test_retry.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ async def test_retry_remove_expired(
113113

114114
metrics = await retry_failed(item_executor=mock_executor, queue=mock_queue)
115115
mock_queue.retrieve.assert_called_once()
116-
assert (
117-
len(mock_queue.done.call_args_list) == 2
118-
), "both items should have been marked as done"
116+
assert len(mock_queue.done.call_args_list) == 2, (
117+
"both items should have been marked as done"
118+
)
119119
assert caplog.text.count("failed to reprocess event") == 0
120120
assert caplog.text.count("removing expired event") == 1
121121
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(
140140
mock.DEFAULT,
141141
]
142142
metrics = await retry_failed(item_executor=mock_executor, queue=mock_queue)
143-
assert (
144-
len(mock_queue.done.call_args_list) == 2
145-
), "both items should have been marked as done"
143+
assert len(mock_queue.done.call_args_list) == 2, (
144+
"both items should have been marked as done"
145+
)
146146
assert caplog.text.count("removing invalid event") == 1
147147
assert metrics == {
148148
"bug_count": 1,

tests/unit/test_steps.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,37 @@ def test_update_issue_points(
984984
)
985985

986986

987+
def test_update_issue_points_removed(
988+
action_context_factory,
989+
mocked_jira,
990+
action_params_factory,
991+
webhook_event_change_factory,
992+
):
993+
action_context = action_context_factory(
994+
operation=Operation.UPDATE,
995+
current_step="maybe_update_issue_points",
996+
bug__see_also=["https://mozilla.atlassian.net/browse/JBI-234"],
997+
jira__issue="JBI-234",
998+
bug__cf_fx_points="---",
999+
event__action="modify",
1000+
event__changes=[
1001+
webhook_event_change_factory(field="cf_fx_points", removed="?", added="0")
1002+
],
1003+
)
1004+
1005+
params = action_params_factory(
1006+
jira_project_key=action_context.jira.project,
1007+
)
1008+
steps.maybe_update_issue_points(
1009+
action_context, parameters=params, jira_service=JiraService(mocked_jira)
1010+
)
1011+
1012+
mocked_jira.create_issue.assert_not_called()
1013+
mocked_jira.update_issue_field.assert_called_with(
1014+
key="JBI-234", fields={"customfield_10037": 0}
1015+
)
1016+
1017+
9871018
def test_update_issue_points_missing_in_map(
9881019
action_context_factory,
9891020
mocked_jira,

0 commit comments

Comments
 (0)