summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/gl_objects/snippets.py4
-rw-r--r--gitlab/objects.py7
-rw-r--r--gitlab/tests/test_gitlabobject.py4
3 files changed, 7 insertions, 8 deletions
diff --git a/docs/gl_objects/snippets.py b/docs/gl_objects/snippets.py
index e865b0a..091aef6 100644
--- a/docs/gl_objects/snippets.py
+++ b/docs/gl_objects/snippets.py
@@ -9,7 +9,7 @@ public_snippets = gl.snippets.public()
# get
snippet = gl.snippets.get(snippet_id)
# get the content
-content = snippet.content()
+content = snippet.raw()
# end get
# create
@@ -19,7 +19,7 @@ snippet = gl.snippets.create({'title': 'snippet1',
# end create
# update
-snippet.visibility_level = gitlab.VISIBILITY_PUBLIC
+snippet.visibility_level = gitlab.Project.VISIBILITY_PUBLIC
snippet.save()
# end update
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 97a2165..9ae8612 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1026,7 +1026,7 @@ class Snippet(GitlabObject):
optionalUpdateAttrs = ['title', 'file_name', 'content', 'visibility_level']
shortPrintAttr = 'title'
- def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
+ def raw(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""Return the raw content of a snippet.
Args:
@@ -1038,14 +1038,13 @@ class Snippet(GitlabObject):
chunk_size (int): Size of each chunk.
Returns:
- str: The snippet content
+ str: The snippet content.
Raises:
GitlabConnectionError: If the server cannot be reached.
GitlabGetError: If the server fails to perform the request.
"""
- url = ("/snippets/%(snippet_id)s/raw" %
- {'snippet_id': self.id})
+ url = ("/snippets/%(snippet_id)s/raw" % {'snippet_id': self.id})
r = self.gitlab._raw_get(url, **kwargs)
raise_error_from_response(r, GitlabGetError)
return utils.response_content(r, streamed, action, chunk_size)
diff --git a/gitlab/tests/test_gitlabobject.py b/gitlab/tests/test_gitlabobject.py
index d191c0f..3bffb82 100644
--- a/gitlab/tests/test_gitlabobject.py
+++ b/gitlab/tests/test_gitlabobject.py
@@ -483,9 +483,9 @@ class TestSnippet(unittest.TestCase):
def test_content(self):
with HTTMock(self.resp_content):
data = b'content'
- content = self.obj.content()
+ content = self.obj.raw()
self.assertEqual(content, data)
def test_blob_fail(self):
with HTTMock(self.resp_content_fail):
- self.assertRaises(GitlabGetError, self.obj.content)
+ self.assertRaises(GitlabGetError, self.obj.raw)