Skip to content

Commit

Permalink
added method to retrieve done state
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWesch committed Apr 11, 2024
1 parent 725fcb2 commit 6f0c820
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/intelligence_layer/connectors/jira/jira_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion tests/connectors/jira/test_jira_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand All @@ -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"]

0 comments on commit 6f0c820

Please sign in to comment.