diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2020-02-22 22:55:50 +0100 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2020-02-22 23:00:29 +0100 |
commit | c313c2b01d796418539e42d578fed635f750cdc1 (patch) | |
tree | 7b53057dc000d06b1929a02b11ef929a0ff4be04 /gitlab/tests/test_gitlab.py | |
parent | e8f0921d164c4b7db78e2f62e75eb32094b4456e (diff) | |
download | gitlab-c313c2b01d796418539e42d578fed635f750cdc1.tar.gz |
feat: add support for user memberships API (#1009)
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index b56889a..678c9a2 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -658,6 +658,38 @@ class TestGitlab(unittest.TestCase): self.assertEqual(user.name, "name") self.assertEqual(user.id, 1) + def test_user_memberships(self): + @urlmatch( + scheme="http", + netloc="localhost", + path="/api/v4/users/1/memberships", + method="get", + ) + def resp_get_user_memberships(url, request): + headers = {"content-type": "application/json"} + content = """[ + { + "source_id": 1, + "source_name": "Project one", + "source_type": "Project", + "access_level": "20" + }, + { + "source_id": 3, + "source_name": "Group three", + "source_type": "Namespace", + "access_level": "20" + } + ]""" + content = content.encode("utf-8") + return response(200, content, headers, None, 5, request) + + with HTTMock(resp_get_user_memberships): + user = self.gl.users.get(1, lazy=True) + memberships = user.memberships.list() + self.assertIsInstance(memberships[0], UserMembership) + self.assertEqual(memberships[0].source_type, "Project") + def test_user_status(self): @urlmatch( scheme="http", |