Skip to content

Commit 13755d8

Browse files
fix: add support for projects.groups.*
Add support for `projects.groups.*` endpoints. Closes #1717
1 parent 8d4c953 commit 13755d8

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

gitlab/v4/objects/projects.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ class GroupProjectManager(ListMixin, RESTManager):
109109
)
110110

111111

112+
class ProjectGroup(RESTObject):
113+
pass
114+
115+
116+
class ProjectGroupManager(ListMixin, RESTManager):
117+
_path = "/projects/{project_id}/groups"
118+
_obj_cls = ProjectGroup
119+
_from_parent_attrs = {"project_id": "id"}
120+
_list_filters = (
121+
"search",
122+
"skip_groups",
123+
"with_shared",
124+
"shared_min_access_level",
125+
"shared_visible_only",
126+
)
127+
_types = {"skip_groups": types.ListAttribute}
128+
129+
112130
class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTObject):
113131
_short_print_attr = "path"
114132

@@ -132,6 +150,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
132150
files: ProjectFileManager
133151
forks: "ProjectForkManager"
134152
generic_packages: GenericPackageManager
153+
groups: ProjectGroupManager
135154
hooks: ProjectHookManager
136155
imports: ProjectImportManager
137156
issues: ProjectIssueManager

tests/functional/api/test_projects.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,26 @@ def test_project_wiki(project):
311311
wiki.save()
312312
wiki.delete()
313313
assert len(project.wikis.list()) == 0
314+
315+
316+
def test_project_share_group(gl, group):
317+
"""Test sharing a project with a group"""
318+
gl.enable_debug()
319+
group2 = gl.groups.create(
320+
{"name": "group2_proj", "path": "group2_proj", "parent_id": group.id}
321+
)
322+
323+
print(group)
324+
print(group2)
325+
326+
data = {
327+
"name": "test-project-tpsg",
328+
"namespace_id": group2.id,
329+
}
330+
project = gl.projects.create(data)
331+
332+
# See if waiting for sidekiq helps us...
333+
groups = project.groups.list()
334+
# assert len(groups) == 2
335+
336+
assert groups is None

0 commit comments

Comments
 (0)