Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gitlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,14 +1071,17 @@ def creategroup(self, name, path, **kwargs):
msg = request.json()['message']
raise exceptions.HttpError(msg)

def getgroups(self, group_id=None, page=1, per_page=20):
def getgroups(self, group_id=None, search=None, page=1, per_page=20):
"""Retrieve group information

:param group_id: Specify a group. Otherwise, all groups are returned
:return: list of groups
"""
data = {'page': page, 'per_page': per_page}

if search:
data['search'] = search

request = requests.get("{0}/{1}".format(self.groups_url,
group_id if group_id else ""),
params=data, headers=self.headers, timeout=self.timeout,
Expand Down
5 changes: 5 additions & 0 deletions gitlab_tests/pyapi-gitlab_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ def test_group(self):
self.assertFalse(self.git.addgroupmember(group["id"], self.user_id, "nonexistant"))
self.assertTrue(self.git.deletegroup(group_id=group["id"]))

self.git.creategroup("not_the_group", "not_the_group")
not_the_group = self.git.getgroups(search="not_the_group")[0]
self.assertNotEqual(not_the_group["id"], group["id"])
self.assertEqual(not_the_group["name"], "not_the_group")

def test_namespaces(self):
assert isinstance(self.git.getnamespaces(), list)
group = self.git.getgroups()[0]
Expand Down