| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0c4d320 commit 6d0e2cb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,18 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | 10 | class TestApplicationAppearance: | |
| 11 | - @pytest.fixture | ||
| 12 | - def gl(self): | ||
| 13 | - return AsyncGitlab( | ||
| 14 | - "http://localhost", | ||
| 15 | - private_token="private_token", | ||
| 16 | - ssl_verify=True, | ||
| 17 | - api_version="4", | ||
| 18 | - ) | ||
| 19 | - | ||
| 20 | 11 | @respx.mock | |
| 21 | 12 | @pytest.mark.asyncio | |
| 22 | - async def test_get_update_appearance(self, gl): | ||
| 13 | + async def test_get_update_appearance(self, gl, gl_get_value, is_gl_sync): | ||
| 23 | 14 | title = "GitLab Test Instance" | |
| 24 | 15 | new_title = "new-title" | |
| 25 | 16 | description = "gitlab-test.example.com" | |
@@ -60,18 +51,23 @@ async def test_get_update_appearance(self, gl): | |||
| 60 | 51 | status_code=StatusCode.OK, | |
| 61 | 52 | ) | |
| 62 | 53 | ||
| 63 | - appearance = await gl.appearance.get() | ||
| 54 | + appearance = gl.appearance.get() | ||
| 55 | + appearance = await gl_get_value(appearance) | ||
| 56 | + | ||
| 64 | 57 | assert appearance.title == title | |
| 65 | 58 | assert appearance.description == description | |
| 66 | 59 | appearance.title = new_title | |
| 67 | 60 | appearance.description = new_description | |
| 68 | - await appearance.save() | ||
| 61 | + if is_gl_sync: | ||
| 62 | + appearance.save() | ||
| 63 | + else: | ||
| 64 | + await appearance.save() | ||
| 69 | 65 | assert appearance.title == new_title | |
| 70 | 66 | assert appearance.description == new_description | |
| 71 | 67 | ||
| 72 | 68 | @respx.mock | |
| 73 | 69 | @pytest.mark.asyncio | |
| 74 | - async def test_update_appearance(self, gl): | ||
| 70 | + async def test_update_appearance(self, gl, is_gl_sync): | ||
| 75 | 71 | new_title = "new-title" | |
| 76 | 72 | new_description = "new-description" | |
| 77 | 73 | ||
@@ -93,4 +89,7 @@ async def test_update_appearance(self, gl): | |||
| 93 | 89 | status_code=StatusCode.OK, | |
| 94 | 90 | ) | |
| 95 | 91 | ||
| 96 | - await gl.appearance.update(title=new_title, description=new_description) | ||
| 92 | + if is_gl_sync: | ||
| 93 | + gl.appearance.update(title=new_title, description=new_description) | ||
| 94 | + else: | ||
| 95 | + await gl.appearance.update(title=new_title, description=new_description) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1182,7 +1182,7 @@ def merge_requests(self, **kwargs): | |||
| 1182 | 1182 | RESTObjectList: The list of merge requests | |
| 1183 | 1183 | """ | |
| 1184 | 1184 | path = "%s/%s/merge_requests" % (self.manager.path, self.get_id()) | |
| 1185 | - data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 1185 | + data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 1186 | 1186 | manager = GroupIssueManager(self.manager.gitlab, parent=self.manager._parent) | |
| 1187 | 1187 | # FIXME(gpocentek): the computed manager path is not correct | |
| 1188 | 1188 | return RESTObjectList(manager, GroupMergeRequest, data_list) # TODO: ??? | |
@@ -1494,7 +1494,7 @@ def list(self, **kwargs): | |||
| 1494 | 1494 | else: | |
| 1495 | 1495 | path = self._path | |
| 1496 | 1496 | ||
| 1497 | - obj = self.gitlab.http_list(path, **data) # TODO: ??? | ||
| 1497 | + obj = self.gitlab.http_list(path, **data) # TODO: ??? | ||
| 1498 | 1498 | if isinstance(obj, list): | |
| 1499 | 1499 | return [self._obj_cls(self, item) for item in obj] | |
| 1500 | 1500 | else: | |
@@ -1567,10 +1567,10 @@ def content(self, streamed=False, action=None, chunk_size=1024, **kwargs): | |||
| 1567 | 1567 | str: The snippet content | |
| 1568 | 1568 | """ | |
| 1569 | 1569 | path = "/snippets/%s/raw" % self.get_id() | |
| 1570 | - result = self.manager.gitlab.http_get( | ||
| 1570 | + result = self.manager.gitlab.http_get( | ||
| 1571 | 1571 | path, streamed=streamed, raw=True, **kwargs | |
| 1572 | 1572 | ) | |
| 1573 | - return utils.response_content(result, streamed, action) | ||
| 1573 | + return utils.response_content(result, streamed, action) | ||
| 1574 | 1574 | ||
| 1575 | 1575 | ||
| 1576 | 1576 | class SnippetManager(CRUDMixin, RESTManager): | |
@@ -1736,7 +1736,7 @@ def unprotect(self, **kwargs): | |||
| 1736 | 1736 | """ | |
| 1737 | 1737 | id = self.get_id().replace("/", "%2F") | |
| 1738 | 1738 | path = "%s/%s/unprotect" % (self.manager.path, id) | |
| 1739 | - server_data self.manager.gitlab.http_put(path, **kwargs) | ||
| 1739 | + server_data = self.manager.gitlab.http_put(path, **kwargs) | ||
| 1740 | 1740 | return self._change_protected(False, server_data) | |
| 1741 | 1741 | ||
| 1742 | 1742 | ||
@@ -1915,7 +1915,7 @@ def artifacts(self, streamed=False, action=None, chunk_size=1024, **kwargs): | |||
| 1915 | 1915 | str: The artifacts if `streamed` is False, None otherwise. | |
| 1916 | 1916 | """ | |
| 1917 | 1917 | path = "%s/%s/artifacts" % (self.manager.path, self.get_id()) | |
| 1918 | - result = self.manager.gitlab.http_get( | ||
| 1918 | + result = self.manager.gitlab.http_get( | ||
| 1919 | 1919 | path, streamed=streamed, raw=True, **kwargs | |
| 1920 | 1920 | ) | |
| 1921 | 1921 | return utils.response_content(result, streamed, action) | |
@@ -1943,7 +1943,7 @@ def artifact(self, path, streamed=False, action=None, chunk_size=1024, **kwargs) | |||
| 1943 | 1943 | str: The artifacts if `streamed` is False, None otherwise. | |
| 1944 | 1944 | """ | |
| 1945 | 1945 | path = "%s/%s/artifacts/%s" % (self.manager.path, self.get_id(), path) | |
| 1946 | - result = self.manager.gitlab.http_get( | ||
| 1946 | + result = self.manager.gitlab.http_get( | ||
| 1947 | 1947 | path, streamed=streamed, raw=True, **kwargs | |
| 1948 | 1948 | ) | |
| 1949 | 1949 | return utils.response_content(result, streamed, action) | |
@@ -1970,10 +1970,10 @@ def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs): | |||
| 1970 | 1970 | str: The trace | |
| 1971 | 1971 | """ | |
| 1972 | 1972 | path = "%s/%s/trace" % (self.manager.path, self.get_id()) | |
| 1973 | - result = self.manager.gitlab.http_get( | ||
| 1973 | + result = self.manager.gitlab.http_get( | ||
| 1974 | 1974 | path, streamed=streamed, raw=True, **kwargs | |
| 1975 | 1975 | ) | |
| 1976 | - return utils.response_content(result, streamed, action) | ||
| 1976 | + return utils.response_content(result, streamed, action) | ||
| 1977 | 1977 | ||
| 1978 | 1978 | ||
| 1979 | 1979 | class ProjectJobManager(RetrieveMixin, RESTManager): | |
@@ -2423,7 +2423,7 @@ def create(self, data, **kwargs): | |||
| 2423 | 2423 | GitlabCreateError: If the server cannot perform the request | |
| 2424 | 2424 | """ | |
| 2425 | 2425 | self._check_missing_create_attrs(data) | |
| 2426 | - server_data = self.gitlab.http_post(self.path, post_data=data, **kwargs) | ||
| 2426 | + server_data = self.gitlab.http_post(self.path, post_data=data, **kwargs) | ||
| 2427 | 2427 | source_issue = ProjectIssue(self._parent.manager, server_data["source_issue"]) | |
| 2428 | 2428 | target_issue = ProjectIssue(self._parent.manager, server_data["target_issue"]) | |
| 2429 | 2429 | return source_issue, target_issue # TODO: ??? | |
@@ -2475,9 +2475,7 @@ def move(self, to_project_id, **kwargs): | |||
| 2475 | 2475 | """ | |
| 2476 | 2476 | path = "%s/%s/move" % (self.manager.path, self.get_id()) | |
| 2477 | 2477 | data = {"to_project_id": to_project_id} | |
| 2478 | - return self.manager.gitlab.http_post( | ||
| 2479 | - path, post_data=data, **kwargs | ||
| 2480 | - ) | ||
| 2478 | + return self.manager.gitlab.http_post(path, post_data=data, **kwargs) | ||
| 2481 | 2479 | ||
| 2482 | 2480 | @cli.register_custom_action("ProjectIssue") | |
| 2483 | 2481 | @exc.on_http_error(exc.GitlabGetError) | |
@@ -2939,7 +2937,7 @@ def commits(self, **kwargs): | |||
| 2939 | 2937 | """ | |
| 2940 | 2938 | ||
| 2941 | 2939 | path = "%s/%s/commits" % (self.manager.path, self.get_id()) | |
| 2942 | - data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 2940 | + data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 2943 | 2941 | manager = ProjectCommitManager(self.manager.gitlab, parent=self.manager._parent) | |
| 2944 | 2942 | return RESTObjectList(manager, ProjectCommit, data_list) # TODO: ??? | |
| 2945 | 2943 | ||
@@ -2999,9 +2997,7 @@ def approve(self, sha=None, **kwargs): | |||
| 2999 | 2997 | if sha: | |
| 3000 | 2998 | data["sha"] = sha | |
| 3001 | 2999 | ||
| 3002 | - return self.manager.gitlab.http_post( | ||
| 3003 | - path, post_data=data, **kwargs | ||
| 3004 | - ) | ||
| 3000 | + return self.manager.gitlab.http_post(path, post_data=data, **kwargs) | ||
| 3005 | 3001 | ||
| 3006 | 3002 | @cli.register_custom_action("ProjectMergeRequest") | |
| 3007 | 3003 | @exc.on_http_error(exc.GitlabMRApprovalError) | |
@@ -3019,9 +3015,7 @@ def unapprove(self, **kwargs): | |||
| 3019 | 3015 | path = "%s/%s/unapprove" % (self.manager.path, self.get_id()) | |
| 3020 | 3016 | data = {} | |
| 3021 | 3017 | ||
| 3022 | - return self.manager.gitlab.http_post( | ||
| 3023 | - path, post_data=data, **kwargs | ||
| 3024 | - ) | ||
| 3018 | + return self.manager.gitlab.http_post(path, post_data=data, **kwargs) | ||
| 3025 | 3019 | ||
| 3026 | 3020 | @cli.register_custom_action("ProjectMergeRequest") | |
| 3027 | 3021 | @exc.on_http_error(exc.GitlabMRRebaseError) | |
@@ -3163,7 +3157,7 @@ def issues(self, **kwargs): | |||
| 3163 | 3157 | """ | |
| 3164 | 3158 | ||
| 3165 | 3159 | path = "%s/%s/issues" % (self.manager.path, self.get_id()) | |
| 3166 | - data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 3160 | + data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 3167 | 3161 | manager = ProjectIssueManager(self.manager.gitlab, parent=self.manager._parent) | |
| 3168 | 3162 | # FIXME(gpocentek): the computed manager path is not correct | |
| 3169 | 3163 | return RESTObjectList(manager, ProjectIssue, data_list) # TODO: ??? | |
@@ -3189,7 +3183,7 @@ def merge_requests(self, **kwargs): | |||
| 3189 | 3183 | RESTObjectList: The list of merge requests | |
| 3190 | 3184 | """ | |
| 3191 | 3185 | path = "%s/%s/merge_requests" % (self.manager.path, self.get_id()) | |
| 3192 | - data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 3186 | + data_list = self.manager.gitlab.http_list(path, as_list=False, **kwargs) | ||
| 3193 | 3187 | manager = ProjectMergeRequestManager( | |
| 3194 | 3188 | self.manager.gitlab, parent=self.manager._parent | |
| 3195 | 3189 | ) | |
@@ -3455,10 +3449,10 @@ def raw( | |||
| 3455 | 3449 | file_path = file_path.replace("/", "%2F").replace(".", "%2E") | |
| 3456 | 3450 | path = "%s/%s/raw" % (self.path, file_path) | |
| 3457 | 3451 | query_data = {"ref": ref} | |
| 3458 | - result = self.gitlab.http_get( | ||
| 3452 | + result = self.gitlab.http_get( | ||
| 3459 | 3453 | path, query_data=query_data, streamed=streamed, raw=True, **kwargs | |
| 3460 | 3454 | ) | |
| 3461 | - return utils.response_content(result, streamed, action) | ||
| 3455 | + return utils.response_content(result, streamed, action) | ||
| 3462 | 3456 | ||
| 3463 | 3457 | @cli.register_custom_action("ProjectFileManager", ("file_path", "ref")) | |
| 3464 | 3458 | @exc.on_http_error(exc.GitlabListError) | |
@@ -3612,7 +3606,7 @@ def take_ownership(self, **kwargs): | |||
| 3612 | 3606 | GitlabOwnershipError: If the request failed | |
| 3613 | 3607 | """ | |
| 3614 | 3608 | path = "%s/%s/take_ownership" % (self.manager.path, self.get_id()) | |
| 3615 | - server_data = return self.manager.gitlab.http_post(path, **kwargs) | ||
| 3609 | + return self.manager.gitlab.http_post(path, **kwargs) | ||
| 3616 | 3610 | ||
| 3617 | 3611 | ||
| 3618 | 3612 | class ProjectPipelineScheduleManager(CRUDMixin, RESTManager): | |
@@ -3765,10 +3759,10 @@ def content(self, streamed=False, action=None, chunk_size=1024, **kwargs): | |||
| 3765 | 3759 | str: The snippet content | |
| 3766 | 3760 | """ | |
| 3767 | 3761 | path = "%s/%s/raw" % (self.manager.path, self.get_id()) | |
| 3768 | - result = self.manager.gitlab.http_get( | ||
| 3762 | + result = self.manager.gitlab.http_get( | ||
| 3769 | 3763 | path, streamed=streamed, raw=True, **kwargs | |
| 3770 | 3764 | ) | |
| 3771 | - return utils.response_content(result, streamed, action) | ||
| 3765 | + return utils.response_content(result, streamed, action) | ||
| 3772 | 3766 | ||
| 3773 | 3767 | ||
| 3774 | 3768 | class ProjectSnippetManager(CRUDMixin, RESTManager): | |
@@ -3906,7 +3900,7 @@ def get(self, id, **kwargs): | |||
| 3906 | 3900 | GitlabAuthenticationError: If authentication is not correct | |
| 3907 | 3901 | GitlabGetError: If the server cannot perform the request | |
| 3908 | 3902 | """ | |
| 3909 | - obj = super(ProjectServiceManager, self).get(id, **kwargs) | ||
| 3903 | + obj = super(ProjectServiceManager, self).get(id, **kwargs) | ||
| 3910 | 3904 | obj.id = id | |
| 3911 | 3905 | return obj # TODO: ??? | |
| 3912 | 3906 | ||
@@ -3926,7 +3920,7 @@ def update(self, id=None, new_data=None, **kwargs): | |||
| 3926 | 3920 | GitlabUpdateError: If the server cannot perform the request | |
| 3927 | 3921 | """ | |
| 3928 | 3922 | new_data = new_data or {} | |
| 3929 | - super(ProjectServiceManager, self).update(id, new_data, **kwargs) | ||
| 3923 | + super(ProjectServiceManager, self).update(id, new_data, **kwargs) | ||
| 3930 | 3924 | self.id = id # TODO: ??? | |
| 3931 | 3925 | ||
| 3932 | 3926 | @cli.register_custom_action("ProjectServiceManager") | |
@@ -4085,10 +4079,10 @@ def download(self, streamed=False, action=None, chunk_size=1024, **kwargs): | |||
| 4085 | 4079 | str: The blob content if streamed is False, None otherwise | |
| 4086 | 4080 | """ | |
| 4087 | 4081 | path = "/projects/%s/export/download" % self.project_id | |
| 4088 | - result = self.manager.gitlab.http_get( | ||
| 4082 | + result = self.manager.gitlab.http_get( | ||
| 4089 | 4083 | path, streamed=streamed, raw=True, **kwargs | |
| 4090 | 4084 | ) | |
| 4091 | - return utils.response_content(result, streamed, action) | ||
| 4085 | + return utils.response_content(result, streamed, action) | ||
| 4092 | 4086 | ||
| 4093 | 4087 | ||
| 4094 | 4088 | class ProjectExportManager(GetWithoutIdMixin, CreateMixin, RESTManager): | |
@@ -4276,10 +4270,10 @@ def repository_raw_blob( | |||
| 4276 | 4270 | str: The blob content if streamed is False, None otherwise | |
| 4277 | 4271 | """ | |
| 4278 | 4272 | path = "/projects/%s/repository/blobs/%s/raw" % (self.get_id(), sha) | |
| 4279 | - result = self.manager.gitlab.http_get( | ||
| 4273 | + result = self.manager.gitlab.http_get( | ||
| 4280 | 4274 | path, streamed=streamed, raw=True, **kwargs | |
| 4281 | 4275 | ) | |
| 4282 | - return utils.response_content(result, streamed, action) | ||
| 4276 | + return utils.response_content(result, streamed, action) | ||
| 4283 | 4277 | ||
| 4284 | 4278 | @cli.register_custom_action("Project", ("from_", "to")) | |
| 4285 | 4279 | @exc.on_http_error(exc.GitlabGetError) | |
@@ -4353,10 +4347,10 @@ def repository_archive( | |||
| 4353 | 4347 | query_data = {} | |
| 4354 | 4348 | if sha: | |
| 4355 | 4349 | query_data["sha"] = sha | |
| 4356 | - result = self.manager.gitlab.http_get( | ||
| 4350 | + result = self.manager.gitlab.http_get( | ||
| 4357 | 4351 | path, query_data=query_data, raw=True, streamed=streamed, **kwargs | |
| 4358 | 4352 | ) | |
| 4359 | - return utils.response_content(result, streamed, action) | ||
| 4353 | + return utils.response_content(result, streamed, action) | ||
| 4360 | 4354 | ||
| 4361 | 4355 | @cli.register_custom_action("Project", ("forked_from_id",)) | |
| 4362 | 4356 | @exc.on_http_error(exc.GitlabCreateError) | |
@@ -4433,7 +4427,7 @@ def star(self, **kwargs): | |||
| 4433 | 4427 | GitlabCreateError: If the server failed to perform the request | |
| 4434 | 4428 | """ | |
| 4435 | 4429 | path = "/projects/%s/star" % self.get_id() | |
| 4436 | - return self.manager.gitlab.http_post(path, **kwargs) | ||
| 4430 | + return self.manager.gitlab.http_post(path, **kwargs) | ||
| 4437 | 4431 | ||
| 4438 | 4432 | @cli.register_custom_action("Project") | |
| 4439 | 4433 | @exc.on_http_error(exc.GitlabDeleteError) | |
@@ -4544,7 +4538,7 @@ def trigger_pipeline(self, ref, token, variables=None, **kwargs): | |||
| 4544 | 4538 | variables = variables or {} | |
| 4545 | 4539 | path = "/projects/%s/trigger/pipeline" % self.get_id() | |
| 4546 | 4540 | post_data = {"ref": ref, "token": token, "variables": variables} | |
| 4547 | - attrs = self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) | ||
| 4541 | + attrs = self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) | ||
| 4548 | 4542 | return ProjectPipeline(self.pipelines, attrs) # TODO: ??? | |
| 4549 | 4543 | ||
| 4550 | 4544 | @cli.register_custom_action("Project") | |
@@ -4604,9 +4598,13 @@ def upload(self, filename, filedata=None, filepath=None, **kwargs): | |||
| 4604 | 4598 | ||
| 4605 | 4599 | url = "/projects/%(id)s/uploads" % {"id": self.id} | |
| 4606 | 4600 | file_info = {"file": (filename, filedata)} | |
| 4607 | - data = self.manager.gitlab.http_post(url, files=file_info) | ||
| 4601 | + data = self.manager.gitlab.http_post(url, files=file_info) | ||
| 4608 | 4602 | ||
| 4609 | - return {"alt": data["alt"], "url": data["url"], "markdown": data["markdown"]} # TODO: ??? | ||
| 4603 | + return { | ||
| 4604 | + "alt": data["alt"], | ||
| 4605 | + "url": data["url"], | ||
| 4606 | + "markdown": data["markdown"], | ||
| 4607 | + } # TODO: ??? | ||
| 4610 | 4608 | ||
| 4611 | 4609 | @cli.register_custom_action("Project", optional=("wiki",)) | |
| 4612 | 4610 | @exc.on_http_error(exc.GitlabGetError) | |
@@ -4633,10 +4631,10 @@ def snapshot( | |||
| 4633 | 4631 | str: The uncompressed tar archive of the repository | |
| 4634 | 4632 | """ | |
| 4635 | 4633 | path = "/projects/%s/snapshot" % self.get_id() | |
| 4636 | - result = self.manager.gitlab.http_get( | ||
| 4634 | + result = self.manager.gitlab.http_get( | ||
| 4637 | 4635 | path, streamed=streamed, raw=True, **kwargs | |
| 4638 | 4636 | ) | |
| 4639 | - return utils.response_content(result, streamed, action) | ||
| 4637 | + return utils.response_content(result, streamed, action) | ||
| 4640 | 4638 | ||
| 4641 | 4639 | @cli.register_custom_action("Project", ("scope", "search")) | |
| 4642 | 4640 | @exc.on_http_error(exc.GitlabSearchError) | |
@@ -4729,7 +4727,7 @@ def artifact( | |||
| 4729 | 4727 | result = self.manager.gitlab.http_get( | |
| 4730 | 4728 | path, streamed=streamed, raw=True, **kwargs | |
| 4731 | 4729 | ) | |
| 4732 | - return utils.response_content(result, streamed, action) | ||
| 4730 | + return utils.response_content(result, streamed, action) | ||
| 4733 | 4731 | ||
| 4734 | 4732 | ||
| 4735 | 4733 | class ProjectManager(CRUDMixin, RESTManager): | |
@@ -5016,7 +5014,7 @@ def mark_as_done(self, **kwargs): | |||
| 5016 | 5014 | GitlabTodoError: If the server failed to perform the request | |
| 5017 | 5015 | """ | |
| 5018 | 5016 | path = "%s/%s/mark_as_done" % (self.manager.path, self.id) | |
| 5019 | - server_data = return self.manager.gitlab.http_post(path, **kwargs) | ||
| 5017 | + return self.manager.gitlab.http_post(path, **kwargs) | ||
| 5020 | 5018 | ||
| 5021 | 5019 | ||
| 5022 | 5020 | class TodoManager(ListMixin, DeleteMixin, RESTManager): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments