| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe89b94 commit 09d1ec0
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,8 +15,6 @@ | |||
| 15 | 15 | # You should have received a copy of the GNU Lesser General Public License | |
| 16 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 17 | 17 | ||
| 18 | - import warnings | ||
| 19 | - | ||
| 20 | 18 | import gitlab | |
| 21 | 19 | from gitlab import base | |
| 22 | 20 | from gitlab import cli | |
@@ -131,41 +129,6 @@ def list(self, **kwargs): | |||
| 131 | 129 | return base.RESTObjectList(self, self._obj_cls, obj) | |
| 132 | 130 | ||
| 133 | 131 | ||
| 134 | - class GetFromListMixin(ListMixin): | ||
| 135 | - """This mixin is deprecated.""" | ||
| 136 | - | ||
| 137 | - def get(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 | - except exc.GitlabListError: | ||
| 159 | - raise exc.GitlabGetError(response_code=404, | ||
| 160 | - error_message="Not found") | ||
| 161 | - | ||
| 162 | - for obj in gen: | ||
| 163 | - if str(obj.get_id()) == str(id): | ||
| 164 | - return obj | ||
| 165 | - | ||
| 166 | - raise exc.GitlabGetError(response_code=404, error_message="Not found") | ||
| 167 | - | ||
| 168 | - | ||
| 169 | 132 | class RetrieveMixin(ListMixin, GetMixin): | |
| 170 | 133 | pass | |
| 171 | 134 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -517,9 +517,9 @@ def resp_get_issue(url, request): | |||
| 517 | 517 | return response(200, content, headers, None, 5, request) | |
| 518 | 518 | ||
| 519 | 519 | with HTTMock(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') | ||
| 523 | 523 | ||
| 524 | 524 | def test_users(self): | |
| 525 | 525 | @urlmatch(scheme="http", netloc="localhost", path="/api/v4/users/1", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -238,26 +238,6 @@ def resp_cont(url, request): | |||
| 238 | 238 | self.assertEqual(obj.foo, 'bar') | |
| 239 | 239 | self.assertRaises(StopIteration, obj_list.next) | |
| 240 | 240 | ||
| 241 | - def test_get_from_list_mixin(self): | ||
| 242 | - class M(GetFromListMixin, FakeManager): | ||
| 243 | - pass | ||
| 244 | - | ||
| 245 | - @urlmatch(scheme="http", netloc="localhost", path='/api/v4/tests', | ||
| 246 | - method="get") | ||
| 247 | - def resp_cont(url, request): | ||
| 248 | - headers = {'Content-Type': 'application/json'} | ||
| 249 | - content = '[{"id": 42, "foo": "bar"},{"id": 43, "foo": "baz"}]' | ||
| 250 | - return response(200, content, headers, None, 5, request) | ||
| 251 | - | ||
| 252 | - with HTTMock(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 | - | ||
| 261 | 241 | def test_create_mixin_get_attrs(self): | |
| 262 | 242 | class M1(CreateMixin, FakeManager): | |
| 263 | 243 | pass | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,7 +180,7 @@ class UserKey(ObjectDeleteMixin, RESTObject): | |||
| 180 | 180 | pass | |
| 181 | 181 | ||
| 182 | 182 | ||
| 183 | - class UserKeyManager(GetFromListMixin, CreateMixin, DeleteMixin, RESTManager): | ||
| 183 | + class UserKeyManager(ListMixin, CreateMixin, DeleteMixin, RESTManager): | ||
| 184 | 184 | _path = '/users/%(user_id)s/keys' | |
| 185 | 185 | _obj_cls = UserKey | |
| 186 | 186 | _from_parent_attrs = {'user_id': 'id'} | |
@@ -428,7 +428,7 @@ class DeployKey(RESTObject): | |||
| 428 | 428 | pass | |
| 429 | 429 | ||
| 430 | 430 | ||
| 431 | - class DeployKeyManager(GetFromListMixin, RESTManager): | ||
| 431 | + class DeployKeyManager(ListMixin, RESTManager): | ||
| 432 | 432 | _path = '/deploy_keys' | |
| 433 | 433 | _obj_cls = DeployKey | |
| 434 | 434 | ||
@@ -513,7 +513,7 @@ class GroupAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject): | |||
| 513 | 513 | pass | |
| 514 | 514 | ||
| 515 | 515 | ||
| 516 | - class GroupAccessRequestManager(GetFromListMixin, CreateMixin, DeleteMixin, | ||
| 516 | + class GroupAccessRequestManager(ListMixin, CreateMixin, DeleteMixin, | ||
| 517 | 517 | RESTManager): | |
| 518 | 518 | _path = '/groups/%(group_id)s/access_requests' | |
| 519 | 519 | _obj_cls = GroupAccessRequest | |
@@ -535,7 +535,7 @@ class GroupIssue(RESTObject): | |||
| 535 | 535 | pass | |
| 536 | 536 | ||
| 537 | 537 | ||
| 538 | - class GroupIssueManager(GetFromListMixin, RESTManager): | ||
| 538 | + class GroupIssueManager(ListMixin, RESTManager): | ||
| 539 | 539 | _path = '/groups/%(group_id)s/issues' | |
| 540 | 540 | _obj_cls = GroupIssue | |
| 541 | 541 | _from_parent_attrs = {'group_id': 'id'} | |
@@ -648,7 +648,7 @@ class GroupProject(RESTObject): | |||
| 648 | 648 | pass | |
| 649 | 649 | ||
| 650 | 650 | ||
| 651 | - class GroupProjectManager(GetFromListMixin, RESTManager): | ||
| 651 | + class GroupProjectManager(ListMixin, RESTManager): | ||
| 652 | 652 | _path = '/groups/%(group_id)s/projects' | |
| 653 | 653 | _obj_cls = GroupProject | |
| 654 | 654 | _from_parent_attrs = {'group_id': 'id'} | |
@@ -660,7 +660,7 @@ class GroupSubgroup(RESTObject): | |||
| 660 | 660 | pass | |
| 661 | 661 | ||
| 662 | 662 | ||
| 663 | - class GroupSubgroupManager(GetFromListMixin, RESTManager): | ||
| 663 | + class GroupSubgroupManager(ListMixin, RESTManager): | ||
| 664 | 664 | _path = '/groups/%(group_id)s/subgroups' | |
| 665 | 665 | _obj_cls = GroupSubgroup | |
| 666 | 666 | _from_parent_attrs = {'group_id': 'id'} | |
@@ -744,7 +744,7 @@ class Issue(RESTObject): | |||
| 744 | 744 | _short_print_attr = 'title' | |
| 745 | 745 | ||
| 746 | 746 | ||
| 747 | - class IssueManager(GetFromListMixin, RESTManager): | ||
| 747 | + class IssueManager(ListMixin, RESTManager): | ||
| 748 | 748 | _path = '/issues' | |
| 749 | 749 | _obj_cls = Issue | |
| 750 | 750 | _list_filters = ('state', 'labels', 'order_by', 'sort') | |
@@ -1092,7 +1092,7 @@ class ProjectCommitStatus(RESTObject, RefreshMixin): | |||
| 1092 | 1092 | pass | |
| 1093 | 1093 | ||
| 1094 | 1094 | ||
| 1095 | - class ProjectCommitStatusManager(GetFromListMixin, CreateMixin, RESTManager): | ||
| 1095 | + class ProjectCommitStatusManager(ListMixin, CreateMixin, RESTManager): | ||
| 1096 | 1096 | _path = ('/projects/%(project_id)s/repository/commits/%(commit_id)s' | |
| 1097 | 1097 | '/statuses') | |
| 1098 | 1098 | _obj_cls = ProjectCommitStatus | |
@@ -1190,7 +1190,7 @@ class ProjectEnvironment(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 1190 | 1190 | pass | |
| 1191 | 1191 | ||
| 1192 | 1192 | ||
| 1193 | - class ProjectEnvironmentManager(GetFromListMixin, CreateMixin, UpdateMixin, | ||
| 1193 | + class ProjectEnvironmentManager(ListMixin, CreateMixin, UpdateMixin, | ||
| 1194 | 1194 | DeleteMixin, RESTManager): | |
| 1195 | 1195 | _path = '/projects/%(project_id)s/environments' | |
| 1196 | 1196 | _obj_cls = ProjectEnvironment | |
@@ -1779,8 +1779,8 @@ def save(self, **kwargs): | |||
| 1779 | 1779 | self._update_attrs(server_data) | |
| 1780 | 1780 | ||
| 1781 | 1781 | ||
| 1782 | - class ProjectLabelManager(GetFromListMixin, CreateMixin, UpdateMixin, | ||
| 1783 | - DeleteMixin, RESTManager): | ||
| 1782 | + class ProjectLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, | ||
| 1783 | + RESTManager): | ||
| 1784 | 1784 | _path = '/projects/%(project_id)s/labels' | |
| 1785 | 1785 | _obj_cls = ProjectLabel | |
| 1786 | 1786 | _from_parent_attrs = {'project_id': 'id'} | |
@@ -2107,7 +2107,7 @@ class ProjectPipelineJob(ProjectJob): | |||
| 2107 | 2107 | pass | |
| 2108 | 2108 | ||
| 2109 | 2109 | ||
| 2110 | - class ProjectPipelineJobManager(GetFromListMixin, RESTManager): | ||
| 2110 | + class ProjectPipelineJobManager(ListMixin, RESTManager): | ||
| 2111 | 2111 | _path = '/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs' | |
| 2112 | 2112 | _obj_cls = ProjectPipelineJob | |
| 2113 | 2113 | _from_parent_attrs = {'project_id': 'project_id', 'pipeline_id': 'id'} | |
@@ -2344,7 +2344,7 @@ class ProjectAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject): | |||
| 2344 | 2344 | pass | |
| 2345 | 2345 | ||
| 2346 | 2346 | ||
| 2347 | - class ProjectAccessRequestManager(GetFromListMixin, CreateMixin, DeleteMixin, | ||
| 2347 | + class ProjectAccessRequestManager(ListMixin, CreateMixin, DeleteMixin, | ||
| 2348 | 2348 | RESTManager): | |
| 2349 | 2349 | _path = '/projects/%(project_id)s/access_requests' | |
| 2350 | 2350 | _obj_cls = ProjectAccessRequest | |
@@ -2902,7 +2902,7 @@ def mark_as_done(self, **kwargs): | |||
| 2902 | 2902 | self._update_attrs(server_data) | |
| 2903 | 2903 | ||
| 2904 | 2904 | ||
| 2905 | - class TodoManager(GetFromListMixin, DeleteMixin, RESTManager): | ||
| 2905 | + class TodoManager(ListMixin, DeleteMixin, RESTManager): | ||
| 2906 | 2906 | _path = '/todos' | |
| 2907 | 2907 | _obj_cls = Todo | |
| 2908 | 2908 | _list_filters = ('action', 'author_id', 'project_id', 'state', 'type') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -402,10 +402,10 @@ | |||
| 402 | 402 | 'http://fake.env/whatever'}) | |
| 403 | 403 | envs = admin_project.environments.list() | |
| 404 | 404 | assert(len(envs) == 1) | |
| 405 | - env = admin_project.environments.get(envs[0].id) | ||
| 405 | + env = envs[0] | ||
| 406 | 406 | env.external_url = 'http://new.env/whatever' | |
| 407 | 407 | env.save() | |
| 408 | - env = admin_project.environments.get(envs[0].id) | ||
| 408 | + env = admin_project.environments.list()[0] | ||
| 409 | 409 | assert(env.external_url == 'http://new.env/whatever') | |
| 410 | 410 | env.delete() | |
| 411 | 411 | assert(len(admin_project.environments.list()) == 0) | |
@@ -439,7 +439,7 @@ | |||
| 439 | 439 | ||
| 440 | 440 | # labels | |
| 441 | 441 | label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'}) | |
| 442 | - label1 = admin_project.labels.get('label1') | ||
| 442 | + label1 = admin_project.labels.list()[0] | ||
| 443 | 443 | assert(len(admin_project.labels.list()) == 1) | |
| 444 | 444 | label1.new_name = 'label1updated' | |
| 445 | 445 | label1.save() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments