| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,6 +92,11 @@ Create a project in a group:: | |||
| 92 | 92 | group_id = gl.groups.list(search='my-group')[0].id | |
| 93 | 93 | project = gl.projects.create({'name': 'myrepo', 'namespace_id': group_id}) | |
| 94 | 94 | ||
| 95 | + List a project's groups:: | ||
| 96 | + | ||
| 97 | + # Get a list of ancestor/parent groups for a project. | ||
| 98 | + groups = project.groups.list() | ||
| 99 | + | ||
| 95 | 100 | Update a project:: | |
| 96 | 101 | ||
| 97 | 102 | project.snippets_enabled = 1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,6 +109,24 @@ class GroupProjectManager(ListMixin, RESTManager): | |||
| 109 | 109 | ) | |
| 110 | 110 | ||
| 111 | 111 | ||
| 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 | + | ||
| 112 | 130 | class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTObject): | |
| 113 | 131 | _short_print_attr = "path" | |
| 114 | 132 | ||
@@ -132,6 +150,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO | |||
| 132 | 150 | files: ProjectFileManager | |
| 133 | 151 | forks: "ProjectForkManager" | |
| 134 | 152 | generic_packages: GenericPackageManager | |
| 153 | + groups: ProjectGroupManager | ||
| 135 | 154 | hooks: ProjectHookManager | |
| 136 | 155 | imports: ProjectImportManager | |
| 137 | 156 | issues: ProjectIssueManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -311,3 +311,21 @@ def test_project_wiki(project): | |||
| 311 | 311 | wiki.save() | |
| 312 | 312 | wiki.delete() | |
| 313 | 313 | assert len(project.wikis.list()) == 0 | |
| 314 | + | ||
| 315 | + | ||
| 316 | + def test_project_groups_list(gl, group): | ||
| 317 | + """Test listing groups of a project""" | ||
| 318 | + # Create a subgroup of our top-group, we will place our new project inside | ||
| 319 | + # this group. | ||
| 320 | + group2 = gl.groups.create( | ||
| 321 | + {"name": "group2_proj", "path": "group2_proj", "parent_id": group.id} | ||
| 322 | + ) | ||
| 323 | + data = { | ||
| 324 | + "name": "test-project-tpsg", | ||
| 325 | + "namespace_id": group2.id, | ||
| 326 | + } | ||
| 327 | + project = gl.projects.create(data) | ||
| 328 | + | ||
| 329 | + groups = project.groups.list() | ||
| 330 | + group_ids = set([x.id for x in groups]) | ||
| 331 | + assert set((group.id, group2.id)) == group_ids | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments