Skip to content

Commit

Permalink
updated jira.search_issues default behaviour to include all fields (#…
Browse files Browse the repository at this point in the history
…1360)

The `jira.search_issues` documentation states that when nothing is passed to the field parameter, all fields are returned.
https://jira.readthedocs.io/api.html?highlight=search_issues#jira.client.JIRA.search_issues
The "*all" has been set as the default field parameter to achieve this.
  • Loading branch information
Yusuf-TJ committed Apr 18, 2022
1 parent 39a74e5 commit bf29a93
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 1 addition & 3 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@ def search_issues(
startAt: int = 0,
maxResults: int = 50,
validate_query: bool = True,
fields: Optional[Union[str, List[str]]] = None,
fields: Optional[Union[str, List[str]]] = "*all",
expand: Optional[str] = None,
json_result: bool = False,
) -> Union[List[Dict[str, Any]], ResultList[Issue]]:
Expand All @@ -2895,8 +2895,6 @@ def search_issues(
"""
if isinstance(fields, str):
fields = fields.split(",")
else:
fields = list(fields or [])

# this will translate JQL field names to REST API Name
# most people do know the JQL names so this will help them use the API easier
Expand Down
23 changes: 23 additions & 0 deletions tests/resources/test_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ def test_issue(self):
self.assertEqual(issue.key, self.issue_1)
self.assertEqual(issue.fields.summary, "issue 1 from %s" % self.project_b)

def test_issue_search_finds_issue(self):
issues = self.jira.search_issues("key=%s" % self.issue_1)
self.assertEqual(self.issue_1, issues[0].key)

def test_issue_search_return_type(self):
issues = self.jira.search_issues("key=%s" % self.issue_1)
self.assertIsInstance(issues, list)
issues = self.jira.search_issues("key=%s" % self.issue_1, json_result=True)
self.assertIsInstance(issues, dict)

def test_issue_search_only_includes_provided_fields(self):
issues = self.jira.search_issues(
"key=%s" % self.issue_1, fields="comment,assignee"
)
self.assertTrue(hasattr(issues[0].fields, "comment"))
self.assertTrue(hasattr(issues[0].fields, "assignee"))
self.assertFalse(hasattr(issues[0].fields, "reporter"))

def test_issue_search_default_behaviour_included_fields(self):
issues = self.jira.search_issues("key=%s" % self.issue_1)
self.assertTrue(hasattr(issues[0].fields, "reporter"))
self.assertTrue(hasattr(issues[0].fields, "comment"))

def test_issue_get_field(self):
issue = self.jira.issue(self.issue_1)
self.assertEqual(
Expand Down

0 comments on commit bf29a93

Please sign in to comment.