FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: add support for `projects.groups.*` · python-gitlab/python-gitlab@5fbd68b · GitHub

Repository navigation

Commit 5fbd68b

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

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,18 @@ 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, project):
317+
"""Test sharing a project with a group"""
318+
gl.enable_debug()
319+
group1 = gl.groups.create({"name": "group1_proj", "path": "group1_proj"})
320+
group2 = gl.groups.create({"name": "group2_proj", "path": "group2_proj"})
321+
322+
project.share(group_id=group1.id, group_access=gitlab.const.DEVELOPER_ACCESS)
323+
project.share(group_id=group2.id, group_access=gitlab.const.MAINTAINER_ACCESS)
324+
325+
groups = project.groups.list()
326+
# assert len(groups) == 2
327+
328+
assert groups is None

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL