Skip to content

Commit fbdb2bf

Browse files
authored
Add goal field to update/create sprint (#1806)
1 parent 4960d8f commit fbdb2bf

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

jira/client.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -5322,6 +5322,7 @@ def update_sprint(
53225322
startDate: Any | None = None,
53235323
endDate: Any | None = None,
53245324
state: str | None = None,
5325+
goal: str | None = None,
53255326
) -> dict[str, Any]:
53265327
"""Updates the sprint with the given values.
53275328
@@ -5330,7 +5331,8 @@ def update_sprint(
53305331
name (Optional[str]): The name to update your sprint to
53315332
startDate (Optional[Any]): The start date for the sprint
53325333
endDate (Optional[Any]): The start date for the sprint
5333-
state: (Optional[str]): The start date for the sprint
5334+
state: (Optional[str]): The state of the sprint
5335+
goal: (Optional[str]): The goal of the sprint
53345336
53355337
Returns:
53365338
Dict[str, Any]
@@ -5344,6 +5346,8 @@ def update_sprint(
53445346
payload["endDate"] = endDate
53455347
if state:
53465348
payload["state"] = state
5349+
if goal:
5350+
payload["goal"] = goal
53475351

53485352
url = self._get_url(f"sprint/{id}", base=self.AGILE_BASE_URL)
53495353
r = self._session.put(url, data=json.dumps(payload))
@@ -5473,6 +5477,7 @@ def create_sprint(
54735477
board_id: int,
54745478
startDate: Any | None = None,
54755479
endDate: Any | None = None,
5480+
goal: str | None = None,
54765481
) -> Sprint:
54775482
"""Create a new sprint for the ``board_id``.
54785483
@@ -5481,6 +5486,7 @@ def create_sprint(
54815486
board_id (int): Which board the sprint should be assigned.
54825487
startDate (Optional[Any]): Start date for the sprint.
54835488
endDate (Optional[Any]): End date for the sprint.
5489+
goal (Optional[str]): Goal for the sprint.
54845490
54855491
Returns:
54865492
Sprint: The newly created Sprint
@@ -5490,14 +5496,16 @@ def create_sprint(
54905496
payload["startDate"] = startDate
54915497
if endDate:
54925498
payload["endDate"] = endDate
5499+
if goal:
5500+
payload["goal"] = goal
54935501

5494-
raw_issue_json: dict[str, Any]
5502+
raw_sprint_json: dict[str, Any]
54955503
url = self._get_url("sprint", base=self.AGILE_BASE_URL)
54965504
payload["originBoardId"] = board_id
54975505
r = self._session.post(url, data=json.dumps(payload))
5498-
raw_issue_json = json_loads(r)
5506+
raw_sprint_json = json_loads(r)
54995507

5500-
return Sprint(self._options, self._session, raw=raw_issue_json)
5508+
return Sprint(self._options, self._session, raw=raw_sprint_json)
55015509

55025510
def add_issues_to_sprint(self, sprint_id: int, issue_keys: list[str]) -> Response:
55035511
"""Add the issues in ``issue_keys`` to the ``sprint_id``.

tests/resources/test_sprint.py

+31
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def setUp(self):
2222
self.board_name = f"board-{uniq}"
2323
self.sprint_name = f"sprint-{uniq}"
2424
self.filter_name = f"filter-{uniq}"
25+
self.sprint_goal = f"goal-{uniq}"
2526

2627
self.board, self.filter = self._create_board_and_filter()
2728

@@ -76,6 +77,36 @@ def test_create_and_delete(self):
7677
assert sprint.state.upper() == "FUTURE"
7778
# THEN: the sprint .delete() is called successfully
7879

80+
def test_create_with_goal(self):
81+
# GIVEN: The board, sprint name, and goal
82+
# WHEN: we create the sprint
83+
sprint = self.jira.create_sprint(
84+
self.sprint_name, self.board.id, goal=self.sprint_goal
85+
)
86+
# THEN: we create the sprint with a goal
87+
assert isinstance(sprint.id, int)
88+
assert sprint.name == self.sprint_name
89+
assert sprint.goal == self.sprint_goal
90+
91+
def test_update_sprint(self):
92+
# GIVEN: The sprint ID
93+
# WHEN: we update the sprint
94+
sprint = self.jira.create_sprint(
95+
self.sprint_name, self.board.id, goal=self.sprint_goal
96+
)
97+
assert isinstance(sprint.id, int)
98+
assert sprint.name == self.sprint_name
99+
assert sprint.goal == self.sprint_goal
100+
# THEN: the name changes
101+
updated_sprint = self.jira.update_sprint(
102+
sprint.id,
103+
"new_name",
104+
state="future",
105+
startDate="2015-04-11T15:22:00.000+10:00",
106+
endDate="2015-04-20T01:22:00.000+10:00",
107+
)
108+
assert updated_sprint["name"] == "new_name"
109+
79110
def test_add_issue_to_sprint(self):
80111
# GIVEN: The sprint
81112
with self._create_sprint() as sprint:

0 commit comments

Comments
 (0)