Skip to content

Commit 56327ca

Browse files
committed
Fix #248: add 'maybe_update_issue_points' step
1 parent c57f9cf commit 56327ca

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

jbi/bugzilla/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class Bug(BaseModel, frozen=True):
7474
creator: Optional[str] = None
7575
assigned_to: Optional[str] = None
7676
comment: Optional[WebhookComment] = None
77+
# Custom field Firefox for story points
78+
cf_fx_points: Optional[str] = None
7779

7880
@property
7981
def product_component(self) -> str:

jbi/models.py

+13
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ActionParams(BaseModel, frozen=True):
7474
jira_project_key: str
7575
steps: ActionSteps = ActionSteps()
7676
jira_components: JiraComponents = JiraComponents()
77+
jira_cf_fx_points_field: str = "customfield_10037"
7778
jira_severity_field: str = "customfield_10716"
7879
jira_priority_field: str = "priority"
7980
jira_resolution_field: str = "resolution"
@@ -82,6 +83,18 @@ class ActionParams(BaseModel, frozen=True):
8283
priority_map: dict[str, str] = {}
8384
resolution_map: dict[str, str] = {}
8485
severity_map: dict[str, str] = {}
86+
cf_fx_points_map: dict[str, int] = {
87+
"?": 0,
88+
"1": 1,
89+
"2": 2,
90+
"3": 3,
91+
"5": 5,
92+
"7": 7,
93+
"8": 8,
94+
"12": 12,
95+
"13": 13,
96+
"15": 15,
97+
}
8598
issue_type_map: dict[str, str] = {"task": "Task", "defect": "Bug"}
8699

87100

jbi/steps.py

+11
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,17 @@ def maybe_update_issue_severity(
278278
)
279279

280280

281+
def maybe_update_issue_points(
282+
context: ActionContext, *, parameters: ActionParams, jira_service: JiraService
283+
) -> StepResult:
284+
"""
285+
Update the Jira issue story points
286+
"""
287+
return _maybe_update_issue_mapped_field(
288+
"cf_fx_points", context, parameters, jira_service
289+
)
290+
291+
281292
def maybe_update_issue_status(
282293
context: ActionContext, *, parameters: ActionParams, jira_service: JiraService
283294
) -> StepResult:

tests/unit/test_steps.py

+31
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,37 @@ def test_update_issue_severity(
796796
)
797797

798798

799+
def test_update_issue_points(
800+
action_context_factory,
801+
mocked_jira,
802+
action_params_factory,
803+
webhook_event_change_factory,
804+
):
805+
action_context = action_context_factory(
806+
operation=Operation.UPDATE,
807+
current_step="maybe_update_issue_points",
808+
bug__see_also=["https://mozilla.atlassian.net/browse/JBI-234"],
809+
jira__issue="JBI-234",
810+
bug__cf_fx_points="15",
811+
event__action="modify",
812+
event__changes=[
813+
webhook_event_change_factory(field="cf_fx_points", removed="?", added="15")
814+
],
815+
)
816+
817+
params = action_params_factory(
818+
jira_project_key=action_context.jira.project,
819+
)
820+
steps.maybe_update_issue_points(
821+
action_context, parameters=params, jira_service=JiraService(mocked_jira)
822+
)
823+
824+
mocked_jira.create_issue.assert_not_called()
825+
mocked_jira.update_issue_field.assert_called_with(
826+
key="JBI-234", fields={"customfield_10037": 15}
827+
)
828+
829+
799830
@pytest.mark.parametrize(
800831
"project_components,bug_component,config_components,expected_jira_components,expected_logs",
801832
[

0 commit comments

Comments
 (0)