diff --git a/src/intelligence_layer/connectors/jira/jira_adapter.py b/src/intelligence_layer/connectors/jira/jira_adapter.py index bb07194c8..a453e337a 100644 --- a/src/intelligence_layer/connectors/jira/jira_adapter.py +++ b/src/intelligence_layer/connectors/jira/jira_adapter.py @@ -49,11 +49,16 @@ def update_ticket(self, ticket_id: str, new_label: str) -> None: self.jira.issue(ticket_id).update(fields={"labels": [new_label]}) def _issue_to_ticket(self, issue: Issue) -> Ticket: - status_names = ["Done", "Fertig"] + done_state = self._done_state(issue) assert issue.fields.description return Ticket( jira_id=issue.id, text=issue.fields.summary + "\n" + issue.fields.description, labels=issue.fields.labels, - is_active=issue.fields.status.name not in status_names, + is_active=issue.fields.status.name != done_state, ) + + def _done_state(self, issue: Issue) -> str: + done_state = self.jira.transitions(issue)[-1]["name"] + assert isinstance(done_state, str) + return done_state diff --git a/tests/connectors/jira/test_jira_adapter.py b/tests/connectors/jira/test_jira_adapter.py index f547acdfc..0806095a3 100644 --- a/tests/connectors/jira/test_jira_adapter.py +++ b/tests/connectors/jira/test_jira_adapter.py @@ -117,7 +117,8 @@ def test_issue_to_ticket(jira_adapter: JiraAdapter, project_id: str) -> None: def test_ticket_not_active(jira_adapter: JiraAdapter, project_id: str) -> None: issues = setup(jira_adapter, project_id) issue = issues[0] - jira_adapter.jira.transition_issue(issue, "Fertig") + done_state = jira_adapter._done_state(issue) + jira_adapter.jira.transition_issue(issue, done_state) updated_issues = jira_adapter.jira.search_issues( f"project={project_id} and id={issue.id}" ) @@ -129,3 +130,11 @@ def test_ticket_not_active(jira_adapter: JiraAdapter, project_id: str) -> None: assert ticket.text == SUMMARY + "\n" + DESCRIPTION assert ticket.labels == issue.fields.labels assert not ticket.is_active + + +@pytest.mark.skip(reason="currently no CI User for Jira configured") +def test_done_state(jira_adapter: JiraAdapter, project_id: str) -> None: + issues = setup(jira_adapter, project_id) + done_state = jira_adapter._done_state(issues[0]) + + assert done_state in ["Done", "Fertig"]