Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09d1ec0

Browse files
author
Gauvain Pocentek
committed
Drop GetFromListMixin
1 parentfe89b94 commit09d1ec0

File tree

5 files changed

+20
-77
lines changed

5 files changed

+20
-77
lines changed

‎gitlab/mixins.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
importwarnings
19-
2018
importgitlab
2119
fromgitlabimportbase
2220
fromgitlabimportcli
@@ -131,41 +129,6 @@ def list(self, **kwargs):
131129
returnbase.RESTObjectList(self,self._obj_cls,obj)
132130

133131

134-
classGetFromListMixin(ListMixin):
135-
"""This mixin is deprecated."""
136-
137-
defget(self,id,**kwargs):
138-
"""Retrieve a single object.
139-
140-
This Method is deprecated.
141-
142-
Args:
143-
id (int or str): ID of the object to retrieve
144-
**kwargs: Extra options to send to the Gitlab server (e.g. sudo)
145-
146-
Returns:
147-
object: The generated RESTObject
148-
149-
Raises:
150-
GitlabAuthenticationError: If authentication is not correct
151-
GitlabGetError: If the server cannot perform the request
152-
"""
153-
warnings.warn('The get() method for this object is deprecated '
154-
'and will be removed in a future version.',
155-
DeprecationWarning)
156-
try:
157-
gen=self.list()
158-
exceptexc.GitlabListError:
159-
raiseexc.GitlabGetError(response_code=404,
160-
error_message="Not found")
161-
162-
forobjingen:
163-
ifstr(obj.get_id())==str(id):
164-
returnobj
165-
166-
raiseexc.GitlabGetError(response_code=404,error_message="Not found")
167-
168-
169132
classRetrieveMixin(ListMixin,GetMixin):
170133
pass
171134

‎gitlab/tests/test_gitlab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ def resp_get_issue(url, request):
517517
returnresponse(200,content,headers,None,5,request)
518518

519519
withHTTMock(resp_get_issue):
520-
data=self.gl.issues.get(2)
521-
self.assertEqual(data.id,2)
522-
self.assertEqual(data.name,'other_name')
520+
data=self.gl.issues.list()
521+
self.assertEqual(data[1].id,2)
522+
self.assertEqual(data[1].name,'other_name')
523523

524524
deftest_users(self):
525525
@urlmatch(scheme="http",netloc="localhost",path="/api/v4/users/1",

‎gitlab/tests/test_mixins.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,26 +238,6 @@ def resp_cont(url, request):
238238
self.assertEqual(obj.foo,'bar')
239239
self.assertRaises(StopIteration,obj_list.next)
240240

241-
deftest_get_from_list_mixin(self):
242-
classM(GetFromListMixin,FakeManager):
243-
pass
244-
245-
@urlmatch(scheme="http",netloc="localhost",path='/api/v4/tests',
246-
method="get")
247-
defresp_cont(url,request):
248-
headers= {'Content-Type':'application/json'}
249-
content='[{"id": 42, "foo": "bar"},{"id": 43, "foo": "baz"}]'
250-
returnresponse(200,content,headers,None,5,request)
251-
252-
withHTTMock(resp_cont):
253-
mgr=M(self.gl)
254-
obj=mgr.get(42)
255-
self.assertIsInstance(obj,FakeObject)
256-
self.assertEqual(obj.foo,'bar')
257-
self.assertEqual(obj.id,42)
258-
259-
self.assertRaises(GitlabGetError,mgr.get,44)
260-
261241
deftest_create_mixin_get_attrs(self):
262242
classM1(CreateMixin,FakeManager):
263243
pass

‎gitlab/v4/objects.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class UserKey(ObjectDeleteMixin, RESTObject):
180180
pass
181181

182182

183-
classUserKeyManager(GetFromListMixin,CreateMixin,DeleteMixin,RESTManager):
183+
classUserKeyManager(ListMixin,CreateMixin,DeleteMixin,RESTManager):
184184
_path='/users/%(user_id)s/keys'
185185
_obj_cls=UserKey
186186
_from_parent_attrs= {'user_id':'id'}
@@ -428,7 +428,7 @@ class DeployKey(RESTObject):
428428
pass
429429

430430

431-
classDeployKeyManager(GetFromListMixin,RESTManager):
431+
classDeployKeyManager(ListMixin,RESTManager):
432432
_path='/deploy_keys'
433433
_obj_cls=DeployKey
434434

@@ -513,7 +513,7 @@ class GroupAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject):
513513
pass
514514

515515

516-
classGroupAccessRequestManager(GetFromListMixin,CreateMixin,DeleteMixin,
516+
classGroupAccessRequestManager(ListMixin,CreateMixin,DeleteMixin,
517517
RESTManager):
518518
_path='/groups/%(group_id)s/access_requests'
519519
_obj_cls=GroupAccessRequest
@@ -535,7 +535,7 @@ class GroupIssue(RESTObject):
535535
pass
536536

537537

538-
classGroupIssueManager(GetFromListMixin,RESTManager):
538+
classGroupIssueManager(ListMixin,RESTManager):
539539
_path='/groups/%(group_id)s/issues'
540540
_obj_cls=GroupIssue
541541
_from_parent_attrs= {'group_id':'id'}
@@ -648,7 +648,7 @@ class GroupProject(RESTObject):
648648
pass
649649

650650

651-
classGroupProjectManager(GetFromListMixin,RESTManager):
651+
classGroupProjectManager(ListMixin,RESTManager):
652652
_path='/groups/%(group_id)s/projects'
653653
_obj_cls=GroupProject
654654
_from_parent_attrs= {'group_id':'id'}
@@ -660,7 +660,7 @@ class GroupSubgroup(RESTObject):
660660
pass
661661

662662

663-
classGroupSubgroupManager(GetFromListMixin,RESTManager):
663+
classGroupSubgroupManager(ListMixin,RESTManager):
664664
_path='/groups/%(group_id)s/subgroups'
665665
_obj_cls=GroupSubgroup
666666
_from_parent_attrs= {'group_id':'id'}
@@ -744,7 +744,7 @@ class Issue(RESTObject):
744744
_short_print_attr='title'
745745

746746

747-
classIssueManager(GetFromListMixin,RESTManager):
747+
classIssueManager(ListMixin,RESTManager):
748748
_path='/issues'
749749
_obj_cls=Issue
750750
_list_filters= ('state','labels','order_by','sort')
@@ -1092,7 +1092,7 @@ class ProjectCommitStatus(RESTObject, RefreshMixin):
10921092
pass
10931093

10941094

1095-
classProjectCommitStatusManager(GetFromListMixin,CreateMixin,RESTManager):
1095+
classProjectCommitStatusManager(ListMixin,CreateMixin,RESTManager):
10961096
_path= ('/projects/%(project_id)s/repository/commits/%(commit_id)s'
10971097
'/statuses')
10981098
_obj_cls=ProjectCommitStatus
@@ -1190,7 +1190,7 @@ class ProjectEnvironment(SaveMixin, ObjectDeleteMixin, RESTObject):
11901190
pass
11911191

11921192

1193-
classProjectEnvironmentManager(GetFromListMixin,CreateMixin,UpdateMixin,
1193+
classProjectEnvironmentManager(ListMixin,CreateMixin,UpdateMixin,
11941194
DeleteMixin,RESTManager):
11951195
_path='/projects/%(project_id)s/environments'
11961196
_obj_cls=ProjectEnvironment
@@ -1779,8 +1779,8 @@ def save(self, **kwargs):
17791779
self._update_attrs(server_data)
17801780

17811781

1782-
classProjectLabelManager(GetFromListMixin,CreateMixin,UpdateMixin,
1783-
DeleteMixin,RESTManager):
1782+
classProjectLabelManager(ListMixin,CreateMixin,UpdateMixin,DeleteMixin,
1783+
RESTManager):
17841784
_path='/projects/%(project_id)s/labels'
17851785
_obj_cls=ProjectLabel
17861786
_from_parent_attrs= {'project_id':'id'}
@@ -2107,7 +2107,7 @@ class ProjectPipelineJob(ProjectJob):
21072107
pass
21082108

21092109

2110-
classProjectPipelineJobManager(GetFromListMixin,RESTManager):
2110+
classProjectPipelineJobManager(ListMixin,RESTManager):
21112111
_path='/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs'
21122112
_obj_cls=ProjectPipelineJob
21132113
_from_parent_attrs= {'project_id':'project_id','pipeline_id':'id'}
@@ -2344,7 +2344,7 @@ class ProjectAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject):
23442344
pass
23452345

23462346

2347-
classProjectAccessRequestManager(GetFromListMixin,CreateMixin,DeleteMixin,
2347+
classProjectAccessRequestManager(ListMixin,CreateMixin,DeleteMixin,
23482348
RESTManager):
23492349
_path='/projects/%(project_id)s/access_requests'
23502350
_obj_cls=ProjectAccessRequest
@@ -2902,7 +2902,7 @@ def mark_as_done(self, **kwargs):
29022902
self._update_attrs(server_data)
29032903

29042904

2905-
classTodoManager(GetFromListMixin,DeleteMixin,RESTManager):
2905+
classTodoManager(ListMixin,DeleteMixin,RESTManager):
29062906
_path='/todos'
29072907
_obj_cls=Todo
29082908
_list_filters= ('action','author_id','project_id','state','type')

‎tools/python_test_v4.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@
402402
'http://fake.env/whatever'})
403403
envs=admin_project.environments.list()
404404
assert(len(envs)==1)
405-
env=admin_project.environments.get(envs[0].id)
405+
env=envs[0]
406406
env.external_url='http://new.env/whatever'
407407
env.save()
408-
env=admin_project.environments.get(envs[0].id)
408+
env=admin_project.environments.list()[0]
409409
assert(env.external_url=='http://new.env/whatever')
410410
env.delete()
411411
assert(len(admin_project.environments.list())==0)
@@ -439,7 +439,7 @@
439439

440440
# labels
441441
label1=admin_project.labels.create({'name':'label1','color':'#778899'})
442-
label1=admin_project.labels.get('label1')
442+
label1=admin_project.labels.list()[0]
443443
assert(len(admin_project.labels.list())==1)
444444
label1.new_name='label1updated'
445445
label1.save()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp