Skip to content

Commit

Permalink
skip jira tetst for now
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesWesch committed Apr 10, 2024
1 parent 697d378 commit b4cd97b
Showing 1 changed file with 49 additions and 26 deletions.
75 changes: 49 additions & 26 deletions tests/connectors/jira/test_jira_adapter.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,79 @@
import os
from typing import Sequence

from dotenv import load_dotenv
from jira import Issue
from pytest import fixture
import pytest

from intelligence_layer.connectors.jira.jira_adapter import JiraAdapter

PROJECT_ID = "TPIJAJW"

@fixture
def jira_adapter() -> JiraAdapter:
load_dotenv()
return JiraAdapter()

def setup(jira_adapter: JiraAdapter) -> Sequence[Issue]:
issues = jira_adapter.jira.search_issues(f"project={PROJECT_ID}")
for issue in issues:
issue.delete()

@fixture
def project_id() -> str:
project_id = os.environ.get("JIRA_PROJECT_ID")
assert project_id
return project_id


def setup(jira_adapter: JiraAdapter, project_id: str) -> Sequence[Issue]:
old_issues = jira_adapter.jira.search_issues(f"project={project_id}")
for issue in old_issues:
assert isinstance(issue, Issue)
issue.delete() # type: ignore

issues = []
issues.append(jira_adapter.jira.create_issue(project=PROJECT_ID, summary='New issue 1 from jira-python',
description='Look into this one', issuetype={'name': 'Bug'}))

issues.append(jira_adapter.jira.create_issue(project=PROJECT_ID, summary='New issue 2 from jira-python',
description='Look into this one', issuetype={'name': 'Bug'}))

issues.append(
jira_adapter.jira.create_issue(
project=project_id,
summary="New issue 1 from jira-python",
description="Look into this one",
issuetype={"name": "Bug"},
)
)

issues.append(
jira_adapter.jira.create_issue(
project=project_id,
summary="New issue 2 from jira-python",
description="Look into this one",
issuetype={"name": "Bug"},
)
)

issue_dict = {
'project': PROJECT_ID,
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Bug'},
"project": project_id,
"summary": "New issue from jira-python",
"description": "Look into this one",
"issuetype": {"name": "Bug"},
}
issues.append(jira_adapter.jira.create_issue(fields=issue_dict))

return issues

def test_tickets(jira_adapter: JiraAdapter) -> None:
issues = setup(jira_adapter)

tickets = jira_adapter.tickets(PROJECT_ID)
@pytest.mark.skip(reason="currently no CI User for Jira configured")
def test_tickets(jira_adapter: JiraAdapter, project_id: str) -> None:
issues = setup(jira_adapter, project_id)

tickets = jira_adapter.tickets(project_id)

issue_ids = [issue.id for issue in issues]
assert len(issues) == len(tickets)
for ticket in tickets:
assert ticket.jira_id in issue_ids

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

tickets = jira_adapter.tickets_by_id(PROJECT_ID, ids)

assert len(tickets) == 2


tickets = jira_adapter.tickets_by_id(project_id, ids)

assert len(tickets) == 2

0 comments on commit b4cd97b

Please sign in to comment.