| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 306c4b1 commit 98c1307
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,6 +107,10 @@ Get the followings of a user:: | |||
| 107 | 107 | ||
| 108 | 108 | user.following_users.list(get_all=True) | |
| 109 | 109 | ||
| 110 | + List a user's contributed projects:: | ||
| 111 | + | ||
| 112 | + user.contributed_projects.list(get_all=True) | ||
| 113 | + | ||
| 110 | 114 | List a user's starred projects:: | |
| 111 | 115 | ||
| 112 | 116 | user.starred_projects.list(get_all=True) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,8 @@ | |||
| 68 | 68 | "UserMembershipManager", | |
| 69 | 69 | "UserProject", | |
| 70 | 70 | "UserProjectManager", | |
| 71 | + "UserContributedProject", | ||
| 72 | + "UserContributedProjectManager", | ||
| 71 | 73 | ] | |
| 72 | 74 | ||
| 73 | 75 | ||
@@ -182,6 +184,7 @@ class User(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 182 | 184 | memberships: UserMembershipManager | |
| 183 | 185 | personal_access_tokens: UserPersonalAccessTokenManager | |
| 184 | 186 | projects: UserProjectManager | |
| 187 | + contributed_projects: UserContributedProjectManager | ||
| 185 | 188 | starred_projects: StarredProjectManager | |
| 186 | 189 | status: UserStatusManager | |
| 187 | 190 | ||
@@ -665,6 +668,17 @@ def list( | |||
| 665 | 668 | return super().list(path=path, iterator=iterator, **kwargs) | |
| 666 | 669 | ||
| 667 | 670 | ||
| 671 | + class UserContributedProject(RESTObject): | ||
| 672 | + _id_attr = "id" | ||
| 673 | + _repr_attr = "path_with_namespace" | ||
| 674 | + | ||
| 675 | + | ||
| 676 | + class UserContributedProjectManager(ListMixin[UserContributedProject]): | ||
| 677 | + _path = "/users/{user_id}/contributed_projects" | ||
| 678 | + _obj_cls = UserContributedProject | ||
| 679 | + _from_parent_attrs = {"user_id": "id"} | ||
| 680 | + | ||
| 681 | + | ||
| 668 | 682 | class StarredProject(RESTObject): | |
| 669 | 683 | pass | |
| 670 | 684 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,13 @@ | |||
| 7 | 7 | import pytest | |
| 8 | 8 | import responses | |
| 9 | 9 | ||
| 10 | - from gitlab.v4.objects import StarredProject, User, UserMembership, UserStatus | ||
| 10 | + from gitlab.v4.objects import ( | ||
| 11 | + StarredProject, | ||
| 12 | + User, | ||
| 13 | + UserContributedProject, | ||
| 14 | + UserMembership, | ||
| 15 | + UserStatus, | ||
| 16 | + ) | ||
| 11 | 17 | ||
| 12 | 18 | from .test_projects import project_content | |
| 13 | 19 | ||
@@ -242,6 +248,19 @@ def resp_starred_projects(): | |||
| 242 | 248 | yield rsps | |
| 243 | 249 | ||
| 244 | 250 | ||
| 251 | + @pytest.fixture | ||
| 252 | + def resp_contributed_projects(): | ||
| 253 | + with responses.RequestsMock() as rsps: | ||
| 254 | + rsps.add( | ||
| 255 | + method=responses.GET, | ||
| 256 | + url="http://localhost/api/v4/users/1/contributed_projects", | ||
| 257 | + json=[project_content], | ||
| 258 | + content_type="application/json", | ||
| 259 | + status=200, | ||
| 260 | + ) | ||
| 261 | + yield rsps | ||
| 262 | + | ||
| 263 | + | ||
| 245 | 264 | @pytest.fixture | |
| 246 | 265 | def resp_runner_create(): | |
| 247 | 266 | with responses.RequestsMock() as rsps: | |
@@ -314,6 +333,12 @@ def test_list_followers(user, resp_followers_following): | |||
| 314 | 333 | assert followings[1].id == 4 | |
| 315 | 334 | ||
| 316 | 335 | ||
| 336 | + def test_list_contributed_projects(user, resp_contributed_projects): | ||
| 337 | + projects = user.contributed_projects.list() | ||
| 338 | + assert isinstance(projects[0], UserContributedProject) | ||
| 339 | + assert projects[0].id == project_content["id"] | ||
| 340 | + | ||
| 341 | + | ||
| 317 | 342 | def test_list_starred_projects(user, resp_starred_projects): | |
| 318 | 343 | projects = user.starred_projects.list() | |
| 319 | 344 | assert isinstance(projects[0], StarredProject) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments