8000 feat(api): re-add topic delete endpoint · python-gitlab/python-gitlab@d1d96bd · GitHub
[go: up one dir, main page]

Skip to content

Commit d1d96bd

Browse files
nejchJohnVillalovos
authored andcommitted
feat(api): re-add topic delete endpoint
This reverts commit e3035a7.
1 parent 8db6841 commit d1d96bd

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
from gitlab import types
44
from gitlab.base import RequiredOptional, RESTMa 8000 nager, RESTObject
5-
from gitlab.mixins import CreateMixin, RetrieveMixin, SaveMixin, UpdateMixin
5+
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
66

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

1212

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

1616

17-
class TopicManager(CreateMixin, RetrieveMixin, UpdateMixin, RESTManager):
17+
class TopicManager(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
assert updated_topic.description == topic.description
19+
20+
topic.delete()
21+
assert not gl.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+
for topic in gl.topics.list():
43+
topic.delete()
4244
for variable in gl.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
yield rsps
7676

7777

78+
@pytest.fixture
79+
def resp_delete_topic(no_content):
80+
with responses.RequestsMock() as rsps:
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+
yield rsps
89+
90+
7891
def test_list_topics(gl, resp_list_topics):
7992
topics = gl.topics.list()
8093
assert isinstance(topics, list)
@@ -99,3 +112,8 @@ def test_update_topic(gl, resp_update_topic):
99112
topic.name = new_name
100113
topic.save()
101114
assert topic.name == new_name
115+
116+
117+
def test_delete_topic(gl, resp_delete_topic):
118+
topic = gl.topics.get(1, lazy=True)
119+
topic.delete()

0 commit comments

Comments
 (0)
0