|
9 | 9 |
|
10 | 10 | import gitlab |
11 | 11 | from gitlab.v4.objects import GroupDescendantGroup, GroupSubgroup |
| 12 | +from gitlab.v4.objects.projects import GroupProject, SharedProject |
12 | 13 |
|
13 | 14 | content = {"name": "name", "id": 1, "path": "path"} |
| 15 | +projects_content = [ |
| 16 | + { |
| 17 | + "id": 9, |
| 18 | + "description": "foo", |
| 19 | + "default_branch": "master", |
| 20 | + "name": "Html5 Boilerplate", |
| 21 | + "name_with_namespace": "Experimental / Html5 Boilerplate", |
| 22 | + "path": "html5-boilerplate", |
| 23 | + "path_with_namespace": "h5bp/html5-boilerplate", |
| 24 | + "namespace": {"id": 5, "name": "Experimental", "path": "h5bp", "kind": "group"}, |
| 25 | + } |
| 26 | +] |
14 | 27 | subgroup_descgroup_content = [ |
15 | 28 | { |
16 | 29 | "id": 2, |
@@ -80,6 +93,19 @@ def resp_groups(): |
80 | 93 | yield rsps |
81 | 94 |
|
82 | 95 |
|
| 96 | +@pytest.fixture |
| 97 | +def resp_list_group_projects(): |
| 98 | + with responses.RequestsMock() as rsps: |
| 99 | + rsps.add( |
| 100 | + method=responses.GET, |
| 101 | + url=re.compile(r"http://localhost/api/v4/groups/1/projects(/shared)?"), |
| 102 | + json=projects_content, |
| 103 | + content_type="application/json", |
| 104 | + status=200, |
| 105 | + ) |
| 106 | + yield rsps |
| 107 | + |
| 108 | + |
83 | 109 | @pytest.fixture |
84 | 110 | def resp_list_subgroups_descendant_groups(): |
85 | 111 | with responses.RequestsMock() as rsps: |
@@ -211,6 +237,18 @@ def test_create_group_export(group, resp_export): |
211 | 237 | assert export.message == "202 Accepted" |
212 | 238 |
|
213 | 239 |
|
| 240 | +def test_list_group_projects(group, resp_list_group_projects): |
| 241 | + projects = group.projects.list() |
| 242 | + assert isinstance(projects[0], GroupProject) |
| 243 | + assert projects[0].path == projects_content[0]["path"] |
| 244 | + |
| 245 | + |
| 246 | +def test_list_group_shared_projects(group, resp_list_group_projects): |
| 247 | + projects = group.shared_projects.list() |
| 248 | + assert isinstance(projects[0], SharedProject) |
| 249 | + assert projects[0].path == projects_content[0]["path"] |
| 250 | + |
| 251 | + |
214 | 252 | def test_list_group_subgroups(group, resp_list_subgroups_descendant_groups): |
215 | 253 | subgroups = group.subgroups.list() |
216 | 254 | assert isinstance(subgroups[0], GroupSubgroup) |
|
0 commit comments