Skip to content

Commit 62b3dc4

Browse files
committed
test(releases): add unit-tests for release update
1 parent 44a2f92 commit 62b3dc4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/unit/objects/test_releases.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
from gitlab.v4.objects import ProjectReleaseLink
1212

13+
tag_name = "v1.0.0"
1314
encoded_tag_name = "v1%2E0%2E0"
15+
release_name = "demo-release"
16+
release_description = "my-rel-desc"
17+
released_at = "2019-03-15T08:00:00Z"
1418
link_name = "hello-world"
1519
link_url = "https://gitlab.example.com/group/hello/-/jobs/688/artifacts/raw/bin/hello-darwin-amd64"
1620
direct_url = f"https://gitlab.example.com/group/hello/-/releases/{encoded_tag_name}/downloads/hello-world"
@@ -24,6 +28,18 @@
2428
"link_type": "other",
2529
}
2630

31+
release_content = {
32+
"id": 3,
33+
"tag_name": tag_name,
34+
"name": release_name,
35+
"description": release_description,
36+
"milestones": [],
37+
"released_at": released_at,
38+
}
39+
40+
release_url = re.compile(
41+
rf"http://localhost/api/v4/projects/1/releases/{encoded_tag_name}"
42+
)
2743
links_url = re.compile(
2844
rf"http://localhost/api/v4/projects/1/releases/{encoded_tag_name}/assets/links"
2945
)
@@ -100,6 +116,21 @@ def resp_delete_link(no_content):
100116
yield rsps
101117

102118

119+
@pytest.fixture
120+
def resp_update_release():
121+
updated_content = dict(release_content)
122+
123+
with responses.RequestsMock() as rsps:
124+
rsps.add(
125+
method=responses.PUT,
126+
url=release_url,
127+
json=updated_content,
128+
content_type="application/json",
129+
status=200,
130+
)
131+
yield rsps
132+
133+
103134
def test_list_release_links(release, resp_list_links):
104135
links = release.links.list()
105136
assert isinstance(links, list)
@@ -129,3 +160,11 @@ def test_update_release_link(release, resp_update_link):
129160
def test_delete_release_link(release, resp_delete_link):
130161
link = release.links.get(1, lazy=True)
131162
link.delete()
163+
164+
165+
def test_update_release(release, resp_update_release):
166+
release.name = release_name
167+
release.description = release_description
168+
release.save()
169+
assert release.name == release_name
170+
assert release.description == release_description

0 commit comments

Comments
 (0)