Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit271f688

Browse files
chore(topics): 'title' is required when creating a topic
In GitLab >= 15.0 `title` is required when creating a topic.
1 parent69014e9 commit271f688

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

‎docs/gl_objects/topics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Get a specific topic by its ID::
3030

3131
Create a new topic::
3232

33-
topic = gl.topics.create({"name": "my-topic"})
33+
topic = gl.topics.create({"name": "my-topic", "title": "my title"})
3434

3535
Update a topic::
3636

‎gitlab/v4/objects/topics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class TopicManager(CRUDMixin, RESTManager):
1919
_path="/topics"
2020
_obj_cls=Topic
2121
_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"),
2326
)
2427
_update_attrs=RequiredOptional(optional=("avatar","description","name"))
2528
_types= {"avatar":types.ImageAttribute}

‎tests/functional/api/test_topics.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
"""
55

66

7-
deftest_topics(gl):
7+
deftest_topics(gl,gitlab_version):
88
assertnotgl.topics.list()
99

10-
topic=gl.topics.create({"name":"my-topic","description":"My Topic"})
10+
create_dict= {"name":"my-topic","description":"My Topic"}
11+
ifgitlab_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+
)
1116
asserttopic.name=="my-topic"
17+
ifgitlab_version.major>=15:
18+
asserttopic.title=="my topic title"
1219
assertgl.topics.list()
1320

1421
topic.description="My Updated Topic"

‎tests/functional/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
importdataclasses
12
importlogging
23
importtempfile
34
importtime
@@ -12,6 +13,24 @@
1213
fromtests.functionalimporthelpers
1314

1415

16+
@dataclasses.dataclass
17+
classGitlabVersion:
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+
defgitlab_version(gl)->GitlabVersion:
29+
version,revision=gl.version()
30+
major,minor,patch=version.split(".")
31+
returnGitlabVersion(major=major,minor=minor,patch=patch,revision=revision)
32+
33+
1534
@pytest.fixture(scope="session")
1635
deffixture_dir(test_dir):
1736
returntest_dir/"functional"/"fixtures"

‎tests/unit/objects/test_topics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
fromgitlab.v4.objectsimportTopic
99

1010
name="GitLab"
11+
topic_title="topic title"
1112
new_name="gitlab-test"
1213
topic_content= {
1314
"id":1,
1415
"name":name,
16+
"title":topic_title,
1517
"description":"GitLab is an open source end-to-end software development platform.",
1618
"total_projects_count":1000,
1719
"avatar_url":"http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
@@ -102,9 +104,10 @@ def test_get_topic(gl, resp_get_topic):
102104

103105

104106
deftest_create_topic(gl,resp_create_topic):
105-
topic=gl.topics.create({"name":name})
107+
topic=gl.topics.create({"name":name,"title":topic_title})
106108
assertisinstance(topic,Topic)
107109
asserttopic.name==name
110+
asserttopic.title==topic_title
108111

109112

110113
deftest_update_topic(gl,resp_update_topic):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp