diff options
| author | Gauvain Pocentek <gauvain@pocentek.net> | 2016-12-25 08:11:22 +0100 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain@pocentek.net> | 2016-12-25 08:11:22 +0100 |
| commit | 26c8a0f25707dafdf772d1e7ed455ee065b7e277 (patch) | |
| tree | cdce482a800402dc3e7dd04a76842ac882697345 /gitlab/tests/test_gitlabobject.py | |
| parent | b05c0b67f8a024a67cdd16e83e70ced879e5913a (diff) | |
| parent | 6022dfec44c67f7f45b0c3274f5eef02e8ac93f0 (diff) | |
| download | gitlab-26c8a0f25707dafdf772d1e7ed455ee065b7e277.tar.gz | |
Merge branch 'features/personal_snippets' of https://github.com/guyzmo/python-gitlab into guyzmo-features/personal_snippets
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) |
