diff options
| author | Nejc Habjan <hab.nejc@gmail.com> | 2021-10-11 23:32:10 +0200 |
|---|---|---|
| committer | John Villalovos <john@sodarock.com> | 2021-10-14 16:24:28 -0700 |
| commit | 47a56061421fc8048ee5cceaf47ac031c92aa1da (patch) | |
| tree | aa253d8fbfc08ddff400aa4bf04df0dce6e8ad4d /tests/unit | |
| parent | 79785f0bee2ef6cc9872f816a78c13583dfb77ab (diff) | |
| download | gitlab-47a56061421fc8048ee5cceaf47ac031c92aa1da.tar.gz | |
feat(objects): list starred projects of a user
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/objects/test_users.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/unit/objects/test_users.py b/tests/unit/objects/test_users.py index e46a315..a2ea5de 100644 --- a/tests/unit/objects/test_users.py +++ b/tests/unit/objects/test_users.py @@ -1,10 +1,14 @@ """ -GitLab API: https://docs.gitlab.com/ce/api/users.html +GitLab API: +https://docs.gitlab.com/ce/api/users.html +https://docs.gitlab.com/ee/api/projects.html#list-projects-starred-by-a-user """ import pytest import responses -from gitlab.v4.objects import User, UserMembership, UserStatus +from gitlab.v4.objects import StarredProject, User, UserMembership, UserStatus + +from .test_projects import project_content @pytest.fixture @@ -174,6 +178,19 @@ def resp_followers_following(): yield rsps +@pytest.fixture +def resp_starred_projects(): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.GET, + url="http://localhost/api/v4/users/1/starred_projects", + json=[project_content], + content_type="application/json", + status=200, + ) + yield rsps + + def test_get_user(gl, resp_get_user): user = gl.users.get(1) assert isinstance(user, User) @@ -215,3 +232,9 @@ def test_list_followers(user, resp_followers_following): assert followers[0].id == 2 assert isinstance(followings[0], User) assert followings[1].id == 4 + + +def test_list_starred_projects(user, resp_starred_projects): + projects = user.starred_projects.list() + assert isinstance(projects[0], StarredProject) + assert projects[0].id == project_content["id"] |
