summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-08-13 16:50:14 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-08-13 16:53:35 +0200
commit451c17492e1399e2359c761f1fb27982e6596696 (patch)
treeac561efc6400f63dc13da108249668fa037cbbdd
parenta8f6fdd43bba84270ec841eb019ea5c332d26e04 (diff)
downloadgitlab-451c17492e1399e2359c761f1fb27982e6596696.tar.gz
Remove _get_list_or_object() and its tests
-rw-r--r--gitlab/objects.py10
-rw-r--r--gitlab/tests/test_gitlab.py28
-rw-r--r--gitlab/tests/test_gitlabobject.py37
3 files changed, 0 insertions, 75 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index cdef349..60d10ed 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -168,8 +168,6 @@ class GitlabObject(object):
_id_in_update_url = True
_constructorTypes = None
- #: Whether _get_list_or_object should return list or object when id is None
- getListWhenNoId = True
#: Tells if GitLab-api allows retrieving single objects.
canGet = True
#: Tells if GitLab-api allows listing of objects.
@@ -282,13 +280,6 @@ class GitlabObject(object):
raise GitlabGetError("Object not found")
- @classmethod
- def _get_list_or_object(cls, gl, id, **kwargs):
- if id is None and cls.getListWhenNoId:
- return cls.list(gl, **kwargs)
- else:
- return cls.get(gl, id, **kwargs)
-
def _get_object(self, k, v):
if self._constructorTypes and k in self._constructorTypes:
return globals()[self._constructorTypes[k]](self.gitlab, v)
@@ -1604,7 +1595,6 @@ class ProjectFile(GitlabObject):
'commit_message']
optionalCreateAttrs = ['encoding']
requiredDeleteAttrs = ['branch_name', 'commit_message', 'file_path']
- getListWhenNoId = False
shortPrintAttr = 'file_path'
getRequiresId = False
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index c32a561..4adf07f 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -625,34 +625,6 @@ class TestGitlab(unittest.TestCase):
self.assertEqual(self.gl.user.id, id_)
self.assertEqual(type(self.gl.user), CurrentUser)
- def test_get_list_or_object_without_id(self):
- @urlmatch(scheme="http", netloc="localhost", path="/api/v3/projects",
- method="get")
- def resp_cont(url, request):
- headers = {'content-type': 'application/json'}
- content = '[{"name": "testproject", "id": 1}]'.encode("utf-8")
- return response(200, content, headers, None, 5, request)
-
- with HTTMock(resp_cont):
- projs = Project._get_list_or_object(self.gl, None)
- self.assertEqual(len(projs), 1)
- proj = projs[0]
- self.assertEqual(proj.id, 1)
- self.assertEqual(proj.name, "testproject")
-
- def test_get_list_or_object_with_id(self):
- @urlmatch(scheme="http", netloc="localhost", path="/api/v3/projects/1",
- method="get")
- def resp_cont(url, request):
- headers = {'content-type': 'application/json'}
- content = '{"name": "testproject", "id": 1}'.encode("utf-8")
- return response(200, content, headers, None, 5, request)
-
- with HTTMock(resp_cont):
- proj = Project._get_list_or_object(self.gl, 1)
- self.assertEqual(proj.id, 1)
- self.assertEqual(proj.name, "testproject")
-
def test_hooks(self):
@urlmatch(scheme="http", netloc="localhost", path="/api/v3/hooks/1",
method="get")
diff --git a/gitlab/tests/test_gitlabobject.py b/gitlab/tests/test_gitlabobject.py
index ca0149f..cf06a2a 100644
--- a/gitlab/tests/test_gitlabobject.py
+++ b/gitlab/tests/test_gitlabobject.py
@@ -210,43 +210,6 @@ class TestGitlabObject(unittest.TestCase):
self.assertEqual(data[0].name, "name")
self.assertEqual(data[0].id, 1)
- def test_get_list_or_object_with_list(self):
- with HTTMock(resp_list_project):
- gl_object = Project(self.gl, data={"name": "name"})
- data = gl_object._get_list_or_object(self.gl, id=None)
- self.assertEqual(type(data), list)
- self.assertEqual(len(data), 1)
- self.assertEqual(type(data[0]), Project)
- self.assertEqual(data[0].name, "name")
- self.assertEqual(data[0].id, 1)
-
- def test_get_list_or_object_with_get(self):
- with HTTMock(resp_get_project):
- gl_object = Project(self.gl, data={"name": "name"})
- data = gl_object._get_list_or_object(self.gl, id=1)
- self.assertEqual(type(data), Project)
- self.assertEqual(data.name, "name")
- self.assertEqual(data.id, 1)
-
- def test_get_list_or_object_cant_get(self):
- with HTTMock(resp_get_issue):
- gl_object = UserProject(self.gl, data={"name": "name"})
- self.assertRaises(NotImplementedError,
- gl_object._get_list_or_object,
- self.gl, id=1)
-
- def test_get_list_or_object_cantlist(self):
- gl_object = CurrentUser(self.gl, data={"name": "name"})
- self.assertRaises(NotImplementedError, gl_object._get_list_or_object,
- self.gl, id=None)
-
- def test_get_list_or_object_create(self):
- data = {"name": "name"}
- gl_object = Project(self.gl, data=data)
- data = gl_object._get_list_or_object(Project, id=data)
- self.assertEqual(type(data), Project)
- self.assertEqual(data.name, "name")
-
def test_create_cantcreate(self):
gl_object = CurrentUser(self.gl, data={"username": "testname"})
self.assertRaises(NotImplementedError, gl_object._create)