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

Commitd1d96bd

Browse files
nejchJohnVillalovos
authored andcommitted
feat(api): re-add topic delete endpoint
This reverts commite3035a7.
1 parent8db6841 commitd1d96bd

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

‎docs/gl_objects/topics.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ Update a topic::
3939

4040
# or
4141
gl.topics.update(topic_id, {"description": "My new topic"})
42+
43+
Delete a topic::
44+
45+
topic.delete()
46+
47+
# or
48+
gl.topics.delete(topic_id)

‎gitlab/v4/objects/topics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
fromgitlabimporttypes
44
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
5-
fromgitlab.mixinsimportCreateMixin,RetrieveMixin,SaveMixin,UpdateMixin
5+
fromgitlab.mixinsimportCRUDMixin,ObjectDeleteMixin,SaveMixin
66

77
__all__= [
88
"Topic",
99
"TopicManager",
1010
]
1111

1212

13-
classTopic(SaveMixin,RESTObject):
13+
classTopic(SaveMixin,ObjectDeleteMixin,RESTObject):
1414
pass
1515

1616

17-
classTopicManager(CreateMixin,RetrieveMixin,UpdateMixin,RESTManager):
17+
classTopicManager(CRUDMixin,RESTManager):
1818
_path="/topics"
1919
_obj_cls=Topic
2020
_create_attrs=RequiredOptional(

‎tests/functional/api/test_topics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ def test_topics(gl):
1616

1717
updated_topic=gl.topics.get(topic.id)
1818
assertupdated_topic.description==topic.description
19+
20+
topic.delete()
21+
assertnotgl.topics.list()

‎tests/functional/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def reset_gitlab(gl):
3939
)
4040
deploy_token.delete()
4141
group.delete()
42+
fortopicingl.topics.list():
43+
topic.delete()
4244
forvariableingl.variables.list():
4345
logging.info(f"Marking for deletion variable:{variable.key!r}")
4446
variable.delete()

‎tests/unit/objects/test_topics.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ def resp_update_topic():
7575
yieldrsps
7676

7777

78+
@pytest.fixture
79+
defresp_delete_topic(no_content):
80+
withresponses.RequestsMock()asrsps:
81+
rsps.add(
82+
method=responses.DELETE,
83+
url=topic_url,
84+
json=no_content,
85+
content_type="application/json",
86+
status=204,
87+
)
88+
yieldrsps
89+
90+
7891
deftest_list_topics(gl,resp_list_topics):
7992
topics=gl.topics.list()
8093
assertisinstance(topics,list)
@@ -99,3 +112,8 @@ def test_update_topic(gl, resp_update_topic):
99112
topic.name=new_name
100113
topic.save()
101114
asserttopic.name==new_name
115+
116+
117+
deftest_delete_topic(gl,resp_delete_topic):
118+
topic=gl.topics.get(1,lazy=True)
119+
topic.delete()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp