summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-07-28 21:01:41 -0700
committerJohn L. Villalovos <john@sodarock.com>2022-07-28 21:01:41 -0700
commit271f6880dbb15b56305efc1fc73924ac26fb97ad (patch)
treef6d9faa21e616d6f77f682e230c6c61395275130 /tests
parent69014e9be3a781be6742478af820ea097d004791 (diff)
downloadgitlab-271f6880dbb15b56305efc1fc73924ac26fb97ad.tar.gz
chore(topics): 'title' is required when creating a topic
In GitLab >= 15.0 `title` is required when creating a topic.
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/api/test_topics.py11
-rw-r--r--tests/functional/conftest.py19
-rw-r--r--tests/unit/objects/test_topics.py5
3 files changed, 32 insertions, 3 deletions
diff --git a/tests/functional/api/test_topics.py b/tests/functional/api/test_topics.py
index 7ad71a5..0d6a3ef 100644
--- a/tests/functional/api/test_topics.py
+++ b/tests/functional/api/test_topics.py
@@ -4,11 +4,18 @@ https://docs.gitlab.com/ce/api/topics.html
"""
-def test_topics(gl):
+def test_topics(gl, gitlab_version):
assert not gl.topics.list()
- topic = gl.topics.create({"name": "my-topic", "description": "My Topic"})
+ create_dict = {"name": "my-topic", "description": "My Topic"}
+ if gitlab_version.major >= 15:
+ create_dict["title"] = "my topic title"
+ topic = gl.topics.create(
+ {"name": "my-topic", "title": "my topic title", "description": "My Topic"}
+ )
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"
diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
index 2767b9d..dc4422e 100644
--- a/tests/functional/conftest.py
+++ b/tests/functional/conftest.py
@@ -1,3 +1,4 @@
+import dataclasses
import logging
import tempfile
import time
@@ -12,6 +13,24 @@ import gitlab.base
from tests.functional import helpers
+@dataclasses.dataclass
+class GitlabVersion:
+ major: int
+ minor: int
+ patch: str
+ revision: str
+
+ def __post_init__(self):
+ self.major, self.minor = int(self.major), int(self.minor)
+
+
+@pytest.fixture(scope="session")
+def gitlab_version(gl) -> GitlabVersion:
+ version, revision = gl.version()
+ major, minor, patch = version.split(".")
+ return GitlabVersion(major=major, minor=minor, patch=patch, revision=revision)
+
+
@pytest.fixture(scope="session")
def fixture_dir(test_dir):
return test_dir / "functional" / "fixtures"
diff --git a/tests/unit/objects/test_topics.py b/tests/unit/objects/test_topics.py
index 14b2cfd..46e964e 100644
--- a/tests/unit/objects/test_topics.py
+++ b/tests/unit/objects/test_topics.py
@@ -8,10 +8,12 @@ import responses
from gitlab.v4.objects import Topic
name = "GitLab"
+topic_title = "topic title"
new_name = "gitlab-test"
topic_content = {
"id": 1,
"name": name,
+ "title": topic_title,
"description": "GitLab is an open source end-to-end software development platform.",
"total_projects_count": 1000,
"avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
@@ -102,9 +104,10 @@ def test_get_topic(gl, resp_get_topic):
def test_create_topic(gl, resp_create_topic):
- topic = gl.topics.create({"name": name})
+ topic = gl.topics.create({"name": name, "title": topic_title})
assert isinstance(topic, Topic)
assert topic.name == name
+ assert topic.title == topic_title
def test_update_topic(gl, resp_update_topic):