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

Commit3870af8

Browse files
fix: remove customdelete method for labels
The usage of deleting was incorrect according to the current API.Add tests to show it works with labels needing to be encoded.Also enable the test_group_labels() test function. Previously it wasdisabled.Closes:#1867
1 parent7646360 commit3870af8

File tree

3 files changed

+11
-42
lines changed

3 files changed

+11
-42
lines changed

‎gitlab/v4/objects/labels.py‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fromtypingimportAny,cast,Dict,Optional,TYPE_CHECKING,Union
1+
fromtypingimportAny,cast,Dict,Optional,Union
22

33
fromgitlabimportexceptionsasexc
44
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
@@ -78,25 +78,6 @@ def update( # type: ignore
7878
new_data["name"]=name
7979
returnsuper().update(id=None,new_data=new_data,**kwargs)
8080

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-
defdelete(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-
ifTYPE_CHECKING:
97-
assertself.pathisnotNone
98-
self.gitlab.http_delete(self.path,query_data={"name":name},**kwargs)
99-
10081

10182
classProjectLabel(
10283
PromoteMixin,SubscribableMixin,SaveMixin,ObjectDeleteMixin,RESTObject
@@ -162,22 +143,3 @@ def update( # type: ignore
162143
ifname:
163144
new_data["name"]=name
164145
returnsuper().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-
defdelete(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-
ifTYPE_CHECKING:
182-
assertself.pathisnotNone
183-
self.gitlab.http_delete(self.path,query_data={"name":name},**kwargs)

‎tests/functional/api/test_groups.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def test_groups(gl):
104104
group2.members.delete(gl.user.id)
105105

106106

107-
@pytest.mark.skip(reason="Commented out in legacy test")
108107
deftest_group_labels(group):
109108
group.labels.create({"name":"foo","description":"bar","color":"#112233"})
110109
label=group.labels.get("foo")
@@ -116,6 +115,12 @@ def test_group_labels(group):
116115
assertlabel.description=="baz"
117116
assertlen(group.labels.list())==1
118117

118+
label.new_name="comp:Flat Export"
119+
label.save()
120+
assertlabel.name=="comp:Flat Export"
121+
label=group.labels.get("comp:Flat Export")
122+
assertlabel.name=="comp:Flat Export"
123+
119124
label.delete()
120125
assertlen(group.labels.list())==0
121126

‎tests/functional/api/test_projects.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ def test_project_labels(project):
146146
label=project.labels.get("label")
147147
assertlabel==labels[0]
148148

149-
label.new_name="labelupdated"
149+
label.new_name="comp:Flat Export"
150150
label.save()
151-
assertlabel.name=="labelupdated"
151+
assertlabel.name=="comp:Flat Export"
152+
label=project.labels.get("comp:Flat Export")
153+
assertlabel.name=="comp:Flat Export"
152154

153155
label.subscribe()
154156
assertlabel.subscribedisTrue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp