summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/mixins.py37
-rw-r--r--gitlab/tests/test_gitlab.py6
-rw-r--r--gitlab/tests/test_mixins.py20
-rw-r--r--gitlab/v4/objects.py28
4 files changed, 17 insertions, 74 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index d6304ed..f940d60 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -15,8 +15,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import warnings
-
import gitlab
from gitlab import base
from gitlab import cli
@@ -131,41 +129,6 @@ class ListMixin(object):
return base.RESTObjectList(self, self._obj_cls, obj)
-class GetFromListMixin(ListMixin):
- """This mixin is deprecated."""
-
- def get(self, id, **kwargs):
- """Retrieve a single object.
-
- This Method is deprecated.
-
- Args:
- id (int or str): ID of the object to retrieve
- **kwargs: Extra options to send to the Gitlab server (e.g. sudo)
-
- Returns:
- object: The generated RESTObject
-
- Raises:
- GitlabAuthenticationError: If authentication is not correct
- GitlabGetError: If the server cannot perform the request
- """
- warnings.warn('The get() method for this object is deprecated '
- 'and will be removed in a future version.',
- DeprecationWarning)
- try:
- gen = self.list()
- except exc.GitlabListError:
- raise exc.GitlabGetError(response_code=404,
- error_message="Not found")
-
- for obj in gen:
- if str(obj.get_id()) == str(id):
- return obj
-
- raise exc.GitlabGetError(response_code=404, error_message="Not found")
-
-
class RetrieveMixin(ListMixin, GetMixin):
pass
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index daa2694..34b60b9 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -517,9 +517,9 @@ class TestGitlab(unittest.TestCase):
return response(200, content, headers, None, 5, request)
with HTTMock(resp_get_issue):
- data = self.gl.issues.get(2)
- self.assertEqual(data.id, 2)
- self.assertEqual(data.name, 'other_name')
+ data = self.gl.issues.list()
+ self.assertEqual(data[1].id, 2)
+ self.assertEqual(data[1].name, 'other_name')
def test_users(self):
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1",
diff --git a/gitlab/tests/test_mixins.py b/gitlab/tests/test_mixins.py
index 5c10597..c737953 100644
--- a/gitlab/tests/test_mixins.py
+++ b/gitlab/tests/test_mixins.py
@@ -238,26 +238,6 @@ class TestMixinMethods(unittest.TestCase):
self.assertEqual(obj.foo, 'bar')
self.assertRaises(StopIteration, obj_list.next)
- def test_get_from_list_mixin(self):
- class M(GetFromListMixin, FakeManager):
- pass
-
- @urlmatch(scheme="http", netloc="localhost", path='/api/v4/tests',
- method="get")
- def resp_cont(url, request):
- headers = {'Content-Type': 'application/json'}
- content = '[{"id": 42, "foo": "bar"},{"id": 43, "foo": "baz"}]'
- return response(200, content, headers, None, 5, request)
-
- with HTTMock(resp_cont):
- mgr = M(self.gl)
- obj = mgr.get(42)
- self.assertIsInstance(obj, FakeObject)
- self.assertEqual(obj.foo, 'bar')
- self.assertEqual(obj.id, 42)
-
- self.assertRaises(GitlabGetError, mgr.get, 44)
-
def test_create_mixin_get_attrs(self):
class M1(CreateMixin, FakeManager):
pass
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 0e28f5c..14bad5a 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -180,7 +180,7 @@ class UserKey(ObjectDeleteMixin, RESTObject):
pass
-class UserKeyManager(GetFromListMixin, CreateMixin, DeleteMixin, RESTManager):
+class UserKeyManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
_path = '/users/%(user_id)s/keys'
_obj_cls = UserKey
_from_parent_attrs = {'user_id': 'id'}
@@ -428,7 +428,7 @@ class DeployKey(RESTObject):
pass
-class DeployKeyManager(GetFromListMixin, RESTManager):
+class DeployKeyManager(ListMixin, RESTManager):
_path = '/deploy_keys'
_obj_cls = DeployKey
@@ -513,7 +513,7 @@ class GroupAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject):
pass
-class GroupAccessRequestManager(GetFromListMixin, CreateMixin, DeleteMixin,
+class GroupAccessRequestManager(ListMixin, CreateMixin, DeleteMixin,
RESTManager):
_path = '/groups/%(group_id)s/access_requests'
_obj_cls = GroupAccessRequest
@@ -535,7 +535,7 @@ class GroupIssue(RESTObject):
pass
-class GroupIssueManager(GetFromListMixin, RESTManager):
+class GroupIssueManager(ListMixin, RESTManager):
_path = '/groups/%(group_id)s/issues'
_obj_cls = GroupIssue
_from_parent_attrs = {'group_id': 'id'}
@@ -648,7 +648,7 @@ class GroupProject(RESTObject):
pass
-class GroupProjectManager(GetFromListMixin, RESTManager):
+class GroupProjectManager(ListMixin, RESTManager):
_path = '/groups/%(group_id)s/projects'
_obj_cls = GroupProject
_from_parent_attrs = {'group_id': 'id'}
@@ -660,7 +660,7 @@ class GroupSubgroup(RESTObject):
pass
-class GroupSubgroupManager(GetFromListMixin, RESTManager):
+class GroupSubgroupManager(ListMixin, RESTManager):
_path = '/groups/%(group_id)s/subgroups'
_obj_cls = GroupSubgroup
_from_parent_attrs = {'group_id': 'id'}
@@ -744,7 +744,7 @@ class Issue(RESTObject):
_short_print_attr = 'title'
-class IssueManager(GetFromListMixin, RESTManager):
+class IssueManager(ListMixin, RESTManager):
_path = '/issues'
_obj_cls = Issue
_list_filters = ('state', 'labels', 'order_by', 'sort')
@@ -1092,7 +1092,7 @@ class ProjectCommitStatus(RESTObject, RefreshMixin):
pass
-class ProjectCommitStatusManager(GetFromListMixin, CreateMixin, RESTManager):
+class ProjectCommitStatusManager(ListMixin, CreateMixin, RESTManager):
_path = ('/projects/%(project_id)s/repository/commits/%(commit_id)s'
'/statuses')
_obj_cls = ProjectCommitStatus
@@ -1190,7 +1190,7 @@ class ProjectEnvironment(SaveMixin, ObjectDeleteMixin, RESTObject):
pass
-class ProjectEnvironmentManager(GetFromListMixin, CreateMixin, UpdateMixin,
+class ProjectEnvironmentManager(ListMixin, CreateMixin, UpdateMixin,
DeleteMixin, RESTManager):
_path = '/projects/%(project_id)s/environments'
_obj_cls = ProjectEnvironment
@@ -1779,8 +1779,8 @@ class ProjectLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin,
self._update_attrs(server_data)
-class ProjectLabelManager(GetFromListMixin, CreateMixin, UpdateMixin,
- DeleteMixin, RESTManager):
+class ProjectLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin,
+ RESTManager):
_path = '/projects/%(project_id)s/labels'
_obj_cls = ProjectLabel
_from_parent_attrs = {'project_id': 'id'}
@@ -2107,7 +2107,7 @@ class ProjectPipelineJob(ProjectJob):
pass
-class ProjectPipelineJobManager(GetFromListMixin, RESTManager):
+class ProjectPipelineJobManager(ListMixin, RESTManager):
_path = '/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs'
_obj_cls = ProjectPipelineJob
_from_parent_attrs = {'project_id': 'project_id', 'pipeline_id': 'id'}
@@ -2344,7 +2344,7 @@ class ProjectAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject):
pass
-class ProjectAccessRequestManager(GetFromListMixin, CreateMixin, DeleteMixin,
+class ProjectAccessRequestManager(ListMixin, CreateMixin, DeleteMixin,
RESTManager):
_path = '/projects/%(project_id)s/access_requests'
_obj_cls = ProjectAccessRequest
@@ -2902,7 +2902,7 @@ class Todo(ObjectDeleteMixin, RESTObject):
self._update_attrs(server_data)
-class TodoManager(GetFromListMixin, DeleteMixin, RESTManager):
+class TodoManager(ListMixin, DeleteMixin, RESTManager):
_path = '/todos'
_obj_cls = Todo
_list_filters = ('action', 'author_id', 'project_id', 'state', 'type')