| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,10 @@ | |||
| 1 | - from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union | ||
| 1 | + from typing import Any, cast, Dict, Optional, Union | ||
| 2 | 2 | ||
| 3 | 3 | from gitlab import exceptions as exc | |
| 4 | 4 | from gitlab.base import RequiredOptional, RESTManager, RESTObject | |
| 5 | 5 | from gitlab.mixins import ( | |
| 6 | 6 | CreateMixin, | |
| 7 | 7 | DeleteMixin, | |
| 8 | - ListMixin, | ||
| 9 | 8 | ObjectDeleteMixin, | |
| 10 | 9 | PromoteMixin, | |
| 11 | 10 | RetrieveMixin, | |
@@ -47,7 +46,9 @@ def save(self, **kwargs: Any) -> None: | |||
| 47 | 46 | self._update_attrs(server_data) | |
| 48 | 47 | ||
| 49 | 48 | ||
| 50 | - class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager): | ||
| 49 | + class GroupLabelManager( | ||
| 50 | + RetrieveMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager | ||
| 51 | + ): | ||
| 51 | 52 | _path = "/groups/{group_id}/labels" | |
| 52 | 53 | _obj_cls = GroupLabel | |
| 53 | 54 | _from_parent_attrs = {"group_id": "id"} | |
@@ -58,6 +59,9 @@ class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa | |||
| 58 | 59 | required=("name",), optional=("new_name", "color", "description", "priority") | |
| 59 | 60 | ) | |
| 60 | 61 | ||
| 62 | + def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupLabel: | ||
| 63 | + return cast(GroupLabel, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 64 | + | ||
| 61 | 65 | # Update without ID. | |
| 62 | 66 | # NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore | |
| 63 | 67 | # type error | |
@@ -78,25 +82,6 @@ def update( # type: ignore | |||
| 78 | 82 | new_data["name"] = name | |
| 79 | 83 | return super().update(id=None, new_data=new_data, **kwargs) | |
| 80 | 84 | ||
| 81 | - # Delete without ID. | ||
| 82 | - @exc.on_http_error(exc.GitlabDeleteError) | ||
| 83 | - # NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore | ||
| 84 | - # type error | ||
| 85 | - def delete(self, name: str, **kwargs: Any) -> None: # type: ignore | ||
| 86 | - """Delete a Label on the server. | ||
| 87 | - | ||
| 88 | - Args: | ||
| 89 | - name: The name of the label | ||
| 90 | - **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 91 | - | ||
| 92 | - Raises: | ||
| 93 | - GitlabAuthenticationError: If authentication is not correct | ||
| 94 | - GitlabDeleteError: If the server cannot perform the request | ||
| 95 | - """ | ||
| 96 | - if TYPE_CHECKING: | ||
| 97 | - assert self.path is not None | ||
| 98 | - self.gitlab.http_delete(self.path, query_data={"name": name}, **kwargs) | ||
| 99 | - | ||
| 100 | 85 | ||
| 101 | 86 | class ProjectLabel( | |
| 102 | 87 | PromoteMixin, SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject | |
@@ -162,22 +147,3 @@ def update( # type: ignore | |||
| 162 | 147 | if name: | |
| 163 | 148 | new_data["name"] = name | |
| 164 | 149 | return super().update(id=None, new_data=new_data, **kwargs) | |
| 165 | - | ||
| 166 | - # Delete without ID. | ||
| 167 | - @exc.on_http_error(exc.GitlabDeleteError) | ||
| 168 | - # NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore | ||
| 169 | - # type error | ||
| 170 | - def delete(self, name: str, **kwargs: Any) -> None: # type: ignore | ||
| 171 | - """Delete a Label on the server. | ||
| 172 | - | ||
| 173 | - Args: | ||
| 174 | - name: The name of the label | ||
| 175 | - **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 176 | - | ||
| 177 | - Raises: | ||
| 178 | - GitlabAuthenticationError: If authentication is not correct | ||
| 179 | - GitlabDeleteError: If the server cannot perform the request | ||
| 180 | - """ | ||
| 181 | - if TYPE_CHECKING: | ||
| 182 | - assert self.path is not None | ||
| 183 | - self.gitlab.http_delete(self.path, query_data={"name": name}, **kwargs) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,6 @@ def test_groups(gl): | |||
| 104 | 104 | group2.members.delete(gl.user.id) | |
| 105 | 105 | ||
| 106 | 106 | ||
| 107 | - @pytest.mark.skip(reason="Commented out in legacy test") | ||
| 108 | 107 | def test_group_labels(group): | |
| 109 | 108 | group.labels.create({"name": "foo", "description": "bar", "color": "#112233"}) | |
| 110 | 109 | label = group.labels.get("foo") | |
@@ -116,6 +115,12 @@ def test_group_labels(group): | |||
| 116 | 115 | assert label.description == "baz" | |
| 117 | 116 | assert len(group.labels.list()) == 1 | |
| 118 | 117 | ||
| 118 | + label.new_name = "Label:that requires:encoding" | ||
| 119 | + label.save() | ||
| 120 | + assert label.name == "Label:that requires:encoding" | ||
| 121 | + label = group.labels.get("Label:that requires:encoding") | ||
| 122 | + assert label.name == "Label:that requires:encoding" | ||
| 123 | + | ||
| 119 | 124 | label.delete() | |
| 120 | 125 | assert len(group.labels.list()) == 0 | |
| 121 | 126 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,9 +146,11 @@ def test_project_labels(project): | |||
| 146 | 146 | label = project.labels.get("label") | |
| 147 | 147 | assert label == labels[0] | |
| 148 | 148 | ||
| 149 | - label.new_name = "labelupdated" | ||
| 149 | + label.new_name = "Label:that requires:encoding" | ||
| 150 | 150 | label.save() | |
| 151 | - assert label.name == "labelupdated" | ||
| 151 | + assert label.name == "Label:that requires:encoding" | ||
| 152 | + label = project.labels.get("Label:that requires:encoding") | ||
| 153 | + assert label.name == "Label:that requires:encoding" | ||
| 152 | 154 | ||
| 153 | 155 | label.subscribe() | |
| 154 | 156 | assert label.subscribed is True | |
| Back | FazBrowse Home | New Git URL |
0 commit comments