diff options
author | Max Wittig <max.wittig@siemens.com> | 2020-02-24 13:56:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 13:56:58 +0100 |
commit | f071390dadc4422c7d3cf77171334a617cfd9908 (patch) | |
tree | 32eb77c15ef0b3df6e62ca0fae68c8701b255a1f /gitlab/tests/test_gitlab.py | |
parent | 292dfff5050515d07b2e4f2231e2ec17dc2d5589 (diff) | |
parent | 33889bcbedb4aa421ea5bf83c13abe3168256c62 (diff) | |
download | gitlab-f071390dadc4422c7d3cf77171334a617cfd9908.tar.gz |
Merge pull request #1026 from nejch/feat/user-memberships
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 b5c0ed5..e7f1932 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -675,6 +675,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", |