Skip to content

Commit

Permalink
Fix use of an int for issuetype in .create_issue() (#1445)
Browse files Browse the repository at this point in the history
Jannik Meinecke (<[email protected]>) on behalf of MBition GmbH.
https://github.com/mercedes-benz/foss/blob/master/PROVIDER_INFORMATION.md


Co-authored-by: Martin Locklear <[email protected]>
  • Loading branch information
rynkk and martinlocklear authored Aug 4, 2022
1 parent 1f0a2ae commit 8ee5508
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ def create_issue(
p = data["fields"]["issuetype"]
if isinstance(p, int):
data["fields"]["issuetype"] = {"id": p}
if isinstance(p, (str, int)):
elif isinstance(p, str):
data["fields"]["issuetype"] = {"id": self.issue_type_by_name(str(p)).id}

url = self._get_url("issue")
Expand Down
12 changes: 12 additions & 0 deletions tests/resources/test_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ def test_create_issues_without_prefetch(self):
for issue in issues:
issue["issue"].delete()

def test_create_issue_with_integer_issuetype(self):
# take first existing issuetype to avoid problems due to hardcoded name/id later
issue_types_resolved = self.jira.issue_types()
dyn_it = issue_types_resolved[0]

issue = self.jira.create_issue(
summary="Test issue created using an integer issuetype",
project=self.project_b,
issuetype=int(dyn_it.id),
)
self.assertEqual(issue.get_field("issuetype").name, dyn_it.name)

def test_update_with_fieldargs(self):
issue = self.jira.create_issue(
summary="Test issue for updating with fieldargs",
Expand Down

0 comments on commit 8ee5508

Please sign in to comment.