Skip to content

Commit ce3dd0d

Browse files
author
Gauvain Pocentek
committed
Add 'search' attribute to projects.list()
projects.search() has been deprecated by Gitlab
1 parent 7def297 commit ce3dd0d

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

docs/gl_objects/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
projects = gl.projects.all()
1717

1818
# Search projects
19-
projects = gl.projects.search('query')
19+
projects = gl.projects.list(search='query')
2020
# end list
2121

2222
# get

gitlab/objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,7 @@ class ProjectRunnerManager(BaseManager):
22762276
class Project(GitlabObject):
22772277
_url = '/projects'
22782278
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
2279+
optionalListAttrs = ['search']
22792280
requiredCreateAttrs = ['name']
22802281
optionalCreateAttrs = ['path', 'namespace_id', 'description',
22812282
'issues_enabled', 'merge_requests_enabled',

gitlab/tests/test_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def resp_get_all(url, request):
215215
def test_project_manager_search(self):
216216
mgr = ProjectManager(self.gitlab)
217217

218-
@urlmatch(scheme="http", netloc="localhost",
219-
path="/api/v3/projects/search/foo", method="get")
218+
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/projects",
219+
query="search=foo", method="get")
220220
def resp_get_all(url, request):
221221
headers = {'content-type': 'application/json'}
222222
content = ('[{"name": "foo1", "id": 1}, '
@@ -225,7 +225,7 @@ def resp_get_all(url, request):
225225
return response(200, content, headers, None, 5, request)
226226

227227
with HTTMock(resp_get_all):
228-
data = mgr.search('foo')
228+
data = mgr.list(search='foo')
229229
self.assertEqual(type(data), list)
230230
self.assertEqual(2, len(data))
231231
self.assertEqual(type(data[0]), Project)

tools/python_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145

146146
assert(len(gl.projects.all()) == 4)
147147
assert(len(gl.projects.owned()) == 2)
148-
assert(len(gl.projects.search("admin")) == 1)
148+
assert(len(gl.projects.list(search="admin")) == 1)
149149

150150
# test pagination
151151
l1 = gl.projects.list(per_page=1, page=1)

0 commit comments

Comments
 (0)