diff --git a/docs/api-objects.rst b/docs/api-objects.rst index 3c76d7775..349b7cf83 100644 --- a/docs/api-objects.rst +++ b/docs/api-objects.rst @@ -11,7 +11,6 @@ API examples gl_objects/emojis gl_objects/badges gl_objects/branches - gl_objects/clusters gl_objects/messages gl_objects/ci_lint gl_objects/commits @@ -63,3 +62,4 @@ API examples gl_objects/variables gl_objects/sidekiq gl_objects/wikis + gl_objects/clusters diff --git a/docs/gl_objects/clusters.rst b/docs/gl_objects/clusters.rst index 96edd82b2..ff39dcc89 100644 --- a/docs/gl_objects/clusters.rst +++ b/docs/gl_objects/clusters.rst @@ -1,6 +1,11 @@ -############ -Clusters -############ +##################### +Clusters (DEPRECATED) +##################### + +.. warning:: + Cluster support was deprecated in GitLab 14.5 and disabled by default as of + GitLab 15.0 + Reference --------- diff --git a/docs/gl_objects/topics.rst b/docs/gl_objects/topics.rst index 0ca46d7f0..c9a357318 100644 --- a/docs/gl_objects/topics.rst +++ b/docs/gl_objects/topics.rst @@ -30,7 +30,7 @@ Get a specific topic by its ID:: Create a new topic:: - topic = gl.topics.create({"name": "my-topic"}) + topic = gl.topics.create({"name": "my-topic", "title": "my title"}) Update a topic:: diff --git a/gitlab/v4/objects/topics.py b/gitlab/v4/objects/topics.py index 57b104ee5..143759d3b 100644 --- a/gitlab/v4/objects/topics.py +++ b/gitlab/v4/objects/topics.py @@ -19,7 +19,10 @@ class TopicManager(CRUDMixin, RESTManager): _path = "/topics" _obj_cls = Topic _create_attrs = RequiredOptional( - required=("name",), optional=("avatar", "description") + # NOTE: The `title` field was added and is required in GitLab 15.0 or + # newer. But not present before that. + required=("name",), + optional=("avatar", "description", "title"), ) _update_attrs = RequiredOptional(optional=("avatar", "description", "name")) _types = {"avatar": types.ImageAttribute} diff --git a/tests/functional/api/test_clusters.py b/tests/functional/api/test_clusters.py deleted file mode 100644 index 32d1488ed..000000000 --- a/tests/functional/api/test_clusters.py +++ /dev/null @@ -1,44 +0,0 @@ -def test_project_clusters(project): - cluster = project.clusters.create( - { - "name": "cluster1", - "platform_kubernetes_attributes": { - "api_url": "http://url", - "token": "tokenval", - }, - } - ) - clusters = project.clusters.list() - assert cluster in clusters - - cluster.platform_kubernetes_attributes = {"api_url": "http://newurl"} - cluster.save() - - cluster = project.clusters.list()[0] - assert cluster.platform_kubernetes["api_url"] == "http://newurl" - - cluster.delete() - assert cluster not in project.clusters.list() - - -def test_group_clusters(group): - cluster = group.clusters.create( - { - "name": "cluster1", - "platform_kubernetes_attributes": { - "api_url": "http://url", - "token": "tokenval", - }, - } - ) - clusters = group.clusters.list() - assert cluster in clusters - - cluster.platform_kubernetes_attributes = {"api_url": "http://newurl"} - cluster.save() - - cluster = group.clusters.list()[0] - assert cluster.platform_kubernetes["api_url"] == "http://newurl" - - cluster.delete() - assert cluster not in group.clusters.list() diff --git a/tests/functional/api/test_topics.py b/tests/functional/api/test_topics.py index 7ad71a524..0d6a3ef32 100644 --- a/tests/functional/api/test_topics.py +++ b/tests/functional/api/test_topics.py @@ -4,11 +4,18 @@ """ -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 2767b9d3a..dc4422ea7 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 @@ 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/functional/fixtures/.env b/tests/functional/fixtures/.env index e7be6c98e..9be02fe66 100644 --- a/tests/functional/fixtures/.env +++ b/tests/functional/fixtures/.env @@ -1,2 +1,2 @@ GITLAB_IMAGE=gitlab/gitlab-ee -GITLAB_TAG=14.9.2-ee.0 +GITLAB_TAG=15.2.0-ee.0 diff --git a/tests/unit/objects/test_topics.py b/tests/unit/objects/test_topics.py index 14b2cfddf..46e964ecc 100644 --- a/tests/unit/objects/test_topics.py +++ b/tests/unit/objects/test_topics.py @@ -8,10 +8,12 @@ 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):