Skip to content

Commit

Permalink
check for is_active
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWesch committed Apr 10, 2024
1 parent e34534d commit 725fcb2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/intelligence_layer/connectors/jira/jira_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ 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"]
assert issue.fields.description
return Ticket(
jira_id=issue.id,
text=issue.fields.summary + issue.fields.description,
text=issue.fields.summary + "\n" + issue.fields.description,
labels=issue.fields.labels,
is_active=True, # TODO
is_active=issue.fields.status.name not in status_names,
)
44 changes: 39 additions & 5 deletions tests/connectors/jira/test_jira_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

from intelligence_layer.connectors.jira.jira_adapter import JiraAdapter

SUMMARY = "New issue 1 from jira-python"
DESCRIPTION = "Look into this one"


@fixture
def jira_adapter() -> JiraAdapter:
Expand All @@ -32,8 +35,8 @@ def setup(jira_adapter: JiraAdapter, project_id: str) -> Sequence[Issue]:
issues.append(
jira_adapter.jira.create_issue(
project=project_id,
summary="New issue 1 from jira-python",
description="Look into this one",
summary=SUMMARY,
description=DESCRIPTION,
issuetype={"name": "Bug"},
labels=["old_label"],
)
Expand Down Expand Up @@ -92,6 +95,37 @@ def test_update_ticket(jira_adapter: JiraAdapter, project_id: str) -> None:
updated_issues = jira_adapter.jira.search_issues(
f"project={project_id} and id={id}"
)
for issue in updated_issues:
assert isinstance(issue, Issue)
assert label in issue.fields.labels
assert isinstance(updated_issues, list)
assert isinstance(updated_issues[0], Issue)
assert label in updated_issues[0].fields.labels


@pytest.mark.skip(reason="currently no CI User for Jira configured")
def test_issue_to_ticket(jira_adapter: JiraAdapter, project_id: str) -> None:
issues = setup(jira_adapter, project_id)
issue = issues[0]

ticket = jira_adapter._issue_to_ticket(issue)

assert ticket.jira_id == issue.id
assert ticket.text == SUMMARY + "\n" + DESCRIPTION
assert ticket.labels == issue.fields.labels
assert ticket.is_active


@pytest.mark.skip(reason="currently no CI User for Jira configured")
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")
updated_issues = jira_adapter.jira.search_issues(
f"project={project_id} and id={issue.id}"
)
assert isinstance(updated_issues, list)

ticket = jira_adapter._issue_to_ticket(updated_issues[0])

assert ticket.jira_id == issue.id
assert ticket.text == SUMMARY + "\n" + DESCRIPTION
assert ticket.labels == issue.fields.labels
assert not ticket.is_active

0 comments on commit 725fcb2

Please sign in to comment.