Skip to content

Commit 853c7c8

Browse files
artbycrunkssbarnea
authored andcommitted
Add ability to query groups (#764)
* add ability to query groups * add a test for group
1 parent af39e84 commit 853c7c8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

jira/client.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def emit(self, record):
7878
from jira.resources import Status
7979
from jira.resources import StatusCategory
8080
from jira.resources import User
81+
from jira.resources import Group
8182
from jira.resources import Version
8283
from jira.resources import Votes
8384
from jira.resources import Watchers
@@ -1104,7 +1105,24 @@ def update_filter(self, filter_id,
11041105
raw_filter_json = json.loads(r.text)
11051106
return Filter(self._options, self._session, raw=raw_filter_json)
11061107

1107-
# Groups
1108+
# Groups
1109+
1110+
def group(self, id, expand=None):
1111+
"""Get a group Resource from the server.
1112+
1113+
:param id: ID of the group to get
1114+
:param id: str
1115+
:param expand: Extra information to fetch inside each resource
1116+
:type expand: Optional[Any]
1117+
1118+
:rtype: User
1119+
"""
1120+
group = Group(self._options, self._session)
1121+
params = {}
1122+
if expand is not None:
1123+
params['expand'] = expand
1124+
group.find(id, params=params)
1125+
return group
11081126

11091127
# non-resource
11101128
def groups(self, query=None, exclude=None, maxResults=9999):

tests/tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ def setUp(self):
662662
self.test_manager = JiraTestManager()
663663
self.jira = self.test_manager.jira_admin
664664

665+
def test_group(self):
666+
group = self.jira.group('jira-users')
667+
self.assertEqual(group.name, 'jira-users')
668+
665669
def test_groups(self):
666670
groups = self.jira.groups()
667671
self.assertGreater(len(groups), 0)

0 commit comments

Comments
 (0)