diff options
author | Guyzmo <guyzmo+github@m0g.net> | 2016-11-27 13:43:38 +0100 |
---|---|---|
committer | Guyzmo <guyzmo+github@m0g.net> | 2016-12-24 12:04:22 +0100 |
commit | 6022dfec44c67f7f45b0c3274f5eef02e8ac93f0 (patch) | |
tree | 42e07d92219cac401cb434142d90842b885ddaa8 /gitlab/tests/test_gitlabobject.py | |
parent | 15d336256c0dca756e189fb9746ab60be2d3c886 (diff) | |
download | gitlab-6022dfec44c67f7f45b0c3274f5eef02e8ac93f0.tar.gz |
Added support for Snippets (new API in Gitlab 8.15)
cf [Gitlab-CE MR !6373](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6373)
Signed-off-by: Guyzmo <guyzmo+github@m0g.net>
Diffstat (limited to 'gitlab/tests/test_gitlabobject.py')
-rw-r--r-- | gitlab/tests/test_gitlabobject.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlabobject.py b/gitlab/tests/test_gitlabobject.py index cf06a2a..d191c0f 100644 --- a/gitlab/tests/test_gitlabobject.py +++ b/gitlab/tests/test_gitlabobject.py @@ -455,3 +455,37 @@ class TestProjectSnippet(unittest.TestCase): def test_blob_fail(self): with HTTMock(self.resp_content_fail): self.assertRaises(GitlabGetError, self.obj.content) + + +class TestSnippet(unittest.TestCase): + def setUp(self): + self.gl = Gitlab("http://localhost", private_token="private_token", + email="testuser@test.com", password="testpassword", + ssl_verify=True) + self.obj = Snippet(self.gl, data={"id": 3}) + + @urlmatch(scheme="http", netloc="localhost", + path="/api/v3/snippets/3/raw", + method="get") + def resp_content(self, url, request): + headers = {'content-type': 'application/json'} + content = 'content'.encode("utf-8") + return response(200, content, headers, None, 5, request) + + @urlmatch(scheme="http", netloc="localhost", + path="/api/v3/snippets/3/raw", + method="get") + def resp_content_fail(self, url, request): + headers = {'content-type': 'application/json'} + content = '{"message": "messagecontent" }'.encode("utf-8") + return response(400, content, headers, None, 5, request) + + def test_content(self): + with HTTMock(self.resp_content): + data = b'content' + content = self.obj.content() + self.assertEqual(content, data) + + def test_blob_fail(self): + with HTTMock(self.resp_content_fail): + self.assertRaises(GitlabGetError, self.obj.content) |