diff --git a/jira/client.py b/jira/client.py index 3fe01faf6..0c456a3f9 100644 --- a/jira/client.py +++ b/jira/client.py @@ -5322,6 +5322,7 @@ def update_sprint( startDate: Any | None = None, endDate: Any | None = None, state: str | None = None, + goal: str | None = None, ) -> dict[str, Any]: """Updates the sprint with the given values. @@ -5330,7 +5331,8 @@ def update_sprint( name (Optional[str]): The name to update your sprint to startDate (Optional[Any]): The start date for the sprint endDate (Optional[Any]): The start date for the sprint - state: (Optional[str]): The start date for the sprint + state: (Optional[str]): The state of the sprint + goal: (Optional[str]): The goal of the sprint Returns: Dict[str, Any] @@ -5344,6 +5346,8 @@ def update_sprint( payload["endDate"] = endDate if state: payload["state"] = state + if goal: + payload["goal"] = goal url = self._get_url(f"sprint/{id}", base=self.AGILE_BASE_URL) r = self._session.put(url, data=json.dumps(payload)) @@ -5473,6 +5477,7 @@ def create_sprint( board_id: int, startDate: Any | None = None, endDate: Any | None = None, + goal: str | None = None, ) -> Sprint: """Create a new sprint for the ``board_id``. @@ -5481,6 +5486,7 @@ def create_sprint( board_id (int): Which board the sprint should be assigned. startDate (Optional[Any]): Start date for the sprint. endDate (Optional[Any]): End date for the sprint. + goal (Optional[str]): Goal for the sprint. Returns: Sprint: The newly created Sprint @@ -5490,14 +5496,16 @@ def create_sprint( payload["startDate"] = startDate if endDate: payload["endDate"] = endDate + if goal: + payload["goal"] = goal - raw_issue_json: dict[str, Any] + raw_sprint_json: dict[str, Any] url = self._get_url("sprint", base=self.AGILE_BASE_URL) payload["originBoardId"] = board_id r = self._session.post(url, data=json.dumps(payload)) - raw_issue_json = json_loads(r) + raw_sprint_json = json_loads(r) - return Sprint(self._options, self._session, raw=raw_issue_json) + return Sprint(self._options, self._session, raw=raw_sprint_json) def add_issues_to_sprint(self, sprint_id: int, issue_keys: list[str]) -> Response: """Add the issues in ``issue_keys`` to the ``sprint_id``. diff --git a/tests/resources/test_sprint.py b/tests/resources/test_sprint.py index 81e86fdcc..83c0d43b1 100644 --- a/tests/resources/test_sprint.py +++ b/tests/resources/test_sprint.py @@ -22,6 +22,7 @@ def setUp(self): self.board_name = f"board-{uniq}" self.sprint_name = f"sprint-{uniq}" self.filter_name = f"filter-{uniq}" + self.sprint_goal = f"goal-{uniq}" self.board, self.filter = self._create_board_and_filter() @@ -76,6 +77,36 @@ def test_create_and_delete(self): assert sprint.state.upper() == "FUTURE" # THEN: the sprint .delete() is called successfully + def test_create_with_goal(self): + # GIVEN: The board, sprint name, and goal + # WHEN: we create the sprint + sprint = self.jira.create_sprint( + self.sprint_name, self.board.id, goal=self.sprint_goal + ) + # THEN: we create the sprint with a goal + assert isinstance(sprint.id, int) + assert sprint.name == self.sprint_name + assert sprint.goal == self.sprint_goal + + def test_update_sprint(self): + # GIVEN: The sprint ID + # WHEN: we update the sprint + sprint = self.jira.create_sprint( + self.sprint_name, self.board.id, goal=self.sprint_goal + ) + assert isinstance(sprint.id, int) + assert sprint.name == self.sprint_name + assert sprint.goal == self.sprint_goal + # THEN: the name changes + updated_sprint = self.jira.update_sprint( + sprint.id, + "new_name", + state="future", + startDate="2015-04-11T15:22:00.000+10:00", + endDate="2015-04-20T01:22:00.000+10:00", + ) + assert updated_sprint["name"] == "new_name" + def test_add_issue_to_sprint(self): # GIVEN: The sprint with self._create_sprint() as sprint: