summaryrefslogtreecommitdiff
path: root/tests/functional/api/test_topics.py
blob: 7777725a90bb59ba8d9f3967ac61e7c4a1b300fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
GitLab API:
https://docs.gitlab.com/ce/api/topics.html
"""


def test_topics(gl, gitlab_version):
    assert not gl.topics.list()

    create_dict = {"name": "my-topic", "description": "My Topic"}
    if gitlab_version.major >= 15:
        create_dict["title"] = "my topic title"
    topic = gl.topics.create(create_dict)
    assert topic.name == "my-topic"

    if gitlab_version.major >= 15:
        assert topic.title == "my topic title"

    assert gl.topics.list()

    topic.description = "My Updated Topic"
    topic.save()
    updated_topic = gl.topics.get(topic.id)
    assert updated_topic.description == topic.description

    create_dict = {"name": "my-second-topic", "description": "My Second Topic"}
    if gitlab_version.major >= 15:
        create_dict["title"] = "my second topic title"
    topic2 = gl.topics.create(create_dict)
    merged_topic = gl.topics.merge(topic.id, topic2.id)
    assert merged_topic["id"] == topic2.id

    topic2.delete()
    assert not gl.topics.list()