| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 69014e9 commit 271f688
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ Get a specific topic by its ID:: | |||
| 30 | 30 | ||
| 31 | 31 | Create a new topic:: | |
| 32 | 32 | ||
| 33 | - topic = gl.topics.create({"name": "my-topic"}) | ||
| 33 | + topic = gl.topics.create({"name": "my-topic", "title": "my title"}) | ||
| 34 | 34 | ||
| 35 | 35 | Update a topic:: | |
| 36 | 36 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,10 @@ class TopicManager(CRUDMixin, RESTManager): | |||
| 19 | 19 | _path = "/topics" | |
| 20 | 20 | _obj_cls = Topic | |
| 21 | 21 | _create_attrs = RequiredOptional( | |
| 22 | - required=("name",), optional=("avatar", "description") | ||
| 22 | + # NOTE: The `title` field was added and is required in GitLab 15.0 or | ||
| 23 | + # newer. But not present before that. | ||
| 24 | + required=("name",), | ||
| 25 | + optional=("avatar", "description", "title"), | ||
| 23 | 26 | ) | |
| 24 | 27 | _update_attrs = RequiredOptional(optional=("avatar", "description", "name")) | |
| 25 | 28 | _types = {"avatar": types.ImageAttribute} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,11 +4,18 @@ | |||
| 4 | 4 | """ | |
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | - def test_topics(gl): | ||
| 7 | + def test_topics(gl, gitlab_version): | ||
| 8 | 8 | assert not gl.topics.list() | |
| 9 | 9 | ||
| 10 | - topic = gl.topics.create({"name": "my-topic", "description": "My Topic"}) | ||
| 10 | + create_dict = {"name": "my-topic", "description": "My Topic"} | ||
| 11 | + if gitlab_version.major >= 15: | ||
| 12 | + create_dict["title"] = "my topic title" | ||
| 13 | + topic = gl.topics.create( | ||
| 14 | + {"name": "my-topic", "title": "my topic title", "description": "My Topic"} | ||
| 15 | + ) | ||
| 11 | 16 | assert topic.name == "my-topic" | |
| 17 | + if gitlab_version.major >= 15: | ||
| 18 | + assert topic.title == "my topic title" | ||
| 12 | 19 | assert gl.topics.list() | |
| 13 | 20 | ||
| 14 | 21 | topic.description = "My Updated Topic" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + import dataclasses | ||
| 1 | 2 | import logging | |
| 2 | 3 | import tempfile | |
| 3 | 4 | import time | |
@@ -12,6 +13,24 @@ | |||
| 12 | 13 | from tests.functional import helpers | |
| 13 | 14 | ||
| 14 | 15 | ||
| 16 | + @dataclasses.dataclass | ||
| 17 | + class GitlabVersion: | ||
| 18 | + major: int | ||
| 19 | + minor: int | ||
| 20 | + patch: str | ||
| 21 | + revision: str | ||
| 22 | + | ||
| 23 | + def __post_init__(self): | ||
| 24 | + self.major, self.minor = int(self.major), int(self.minor) | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + @pytest.fixture(scope="session") | ||
| 28 | + def gitlab_version(gl) -> GitlabVersion: | ||
| 29 | + version, revision = gl.version() | ||
| 30 | + major, minor, patch = version.split(".") | ||
| 31 | + return GitlabVersion(major=major, minor=minor, patch=patch, revision=revision) | ||
| 32 | + | ||
| 33 | + | ||
| 15 | 34 | @pytest.fixture(scope="session") | |
| 16 | 35 | def fixture_dir(test_dir): | |
| 17 | 36 | return test_dir / "functional" / "fixtures" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,10 +8,12 @@ | |||
| 8 | 8 | from gitlab.v4.objects import Topic | |
| 9 | 9 | ||
| 10 | 10 | name = "GitLab" | |
| 11 | + topic_title = "topic title" | ||
| 11 | 12 | new_name = "gitlab-test" | |
| 12 | 13 | topic_content = { | |
| 13 | 14 | "id": 1, | |
| 14 | 15 | "name": name, | |
| 16 | + "title": topic_title, | ||
| 15 | 17 | "description": "GitLab is an open source end-to-end software development platform.", | |
| 16 | 18 | "total_projects_count": 1000, | |
| 17 | 19 | "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", | |
@@ -102,9 +104,10 @@ def test_get_topic(gl, resp_get_topic): | |||
| 102 | 104 | ||
| 103 | 105 | ||
| 104 | 106 | def test_create_topic(gl, resp_create_topic): | |
| 105 | - topic = gl.topics.create({"name": name}) | ||
| 107 | + topic = gl.topics.create({"name": name, "title": topic_title}) | ||
| 106 | 108 | assert isinstance(topic, Topic) | |
| 107 | 109 | assert topic.name == name | |
| 110 | + assert topic.title == topic_title | ||
| 108 | 111 | ||
| 109 | 112 | ||
| 110 | 113 | def test_update_topic(gl, resp_update_topic): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments