summaryrefslogtreecommitdiff
path: root/tests/unit/objects/test_releases.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-12-01 01:04:53 +0100
committerGitHub <noreply@github.com>2021-12-01 01:04:53 +0100
commit8d76826fa64460e504acc5924f859f8dbc246b42 (patch)
tree083fefada982c795e2415092794db429abb0c184 /tests/unit/objects/test_releases.py
parent5a1678f43184bd459132102cc13cf8426fe0449d (diff)
parent86ab04e54ea4175f10053decfad5086cda7aa024 (diff)
downloadgitlab-master.tar.gz
Merge pull request #1723 from python-gitlab/jlvillal/dead_mastermaster
Close-out `master` branch
Diffstat (limited to 'tests/unit/objects/test_releases.py')
-rw-r--r--tests/unit/objects/test_releases.py170
1 files changed, 0 insertions, 170 deletions
diff --git a/tests/unit/objects/test_releases.py b/tests/unit/objects/test_releases.py
deleted file mode 100644
index 58ab5d0..0000000
--- a/tests/unit/objects/test_releases.py
+++ /dev/null
@@ -1,170 +0,0 @@
-"""
-GitLab API:
-https://docs.gitlab.com/ee/api/releases/index.html
-https://docs.gitlab.com/ee/api/releases/links.html
-"""
-import re
-
-import pytest
-import responses
-
-from gitlab.v4.objects import ProjectReleaseLink
-
-tag_name = "v1.0.0"
-encoded_tag_name = "v1%2E0%2E0"
-release_name = "demo-release"
-release_description = "my-rel-desc"
-released_at = "2019-03-15T08:00:00Z"
-link_name = "hello-world"
-link_url = "https://gitlab.example.com/group/hello/-/jobs/688/artifacts/raw/bin/hello-darwin-amd64"
-direct_url = f"https://gitlab.example.com/group/hello/-/releases/{encoded_tag_name}/downloads/hello-world"
-new_link_type = "package"
-link_content = {
- "id": 2,
- "name": link_name,
- "url": link_url,
- "direct_asset_url": direct_url,
- "external": False,
- "link_type": "other",
-}
-
-release_content = {
- "id": 3,
- "tag_name": tag_name,
- "name": release_name,
- "description": release_description,
- "milestones": [],
- "released_at": released_at,
-}
-
-release_url = re.compile(
- rf"http://localhost/api/v4/projects/1/releases/{encoded_tag_name}"
-)
-links_url = re.compile(
- rf"http://localhost/api/v4/projects/1/releases/{encoded_tag_name}/assets/links"
-)
-link_id_url = re.compile(
- rf"http://localhost/api/v4/projects/1/releases/{encoded_tag_name}/assets/links/1"
-)
-
-
-@pytest.fixture
-def resp_list_links():
- with responses.RequestsMock() as rsps:
- rsps.add(
- method=responses.GET,
- url=links_url,
- json=[link_content],
- content_type="application/json",
- status=200,
- )
- yield rsps
-
-
-@pytest.fixture
-def resp_get_link():
- with responses.RequestsMock() as rsps:
- rsps.add(
- method=responses.GET,
- url=link_id_url,
- json=link_content,
- content_type="application/json",
- status=200,
- )
- yield rsps
-
-
-@pytest.fixture
-def resp_create_link():
- with responses.RequestsMock() as rsps:
- rsps.add(
- method=responses.POST,
- url=links_url,
- json=link_content,
- content_type="application/json",
- status=200,
- )
- yield rsps
-
-
-@pytest.fixture
-def resp_update_link():
- updated_content = dict(link_content)
- updated_content["link_type"] = new_link_type
-
- with responses.RequestsMock() as rsps:
- rsps.add(
- method=responses.PUT,
- url=link_id_url,
- json=updated_content,
- content_type="application/json",
- status=200,
- )
- yield rsps
-
-
-@pytest.fixture
-def resp_delete_link(no_content):
- with responses.RequestsMock() as rsps:
- rsps.add(
- method=responses.DELETE,
- url=link_id_url,
- json=link_content,
- content_type="application/json",
- status=204,
- )
- yield rsps
-
-
-@pytest.fixture
-def resp_update_release():
- updated_content = dict(release_content)
-
- with responses.RequestsMock() as rsps:
- rsps.add(
- method=responses.PUT,
- url=release_url,
- json=updated_content,
- content_type="application/json",
- status=200,
- )
- yield rsps
-
-
-def test_list_release_links(release, resp_list_links):
- links = release.links.list()
- assert isinstance(links, list)
- assert isinstance(links[0], ProjectReleaseLink)
- assert links[0].url == link_url
-
-
-def test_get_release_link(release, resp_get_link):
- link = release.links.get(1)
- assert isinstance(link, ProjectReleaseLink)
- assert link.url == link_url
-
-
-def test_create_release_link(release, resp_create_link):
- link = release.links.create({"url": link_url, "name": link_name})
- assert isinstance(link, ProjectReleaseLink)
- assert link.url == link_url
-
-
-def test_update_release_link(release, resp_update_link):
- link = release.links.get(1, lazy=True)
- link.link_type = new_link_type
- link.save()
- assert link.link_type == new_link_type
-
-
-def test_delete_release_link(release, resp_delete_link):
- link = release.links.get(1, lazy=True)
- link.delete()
-
-
-def test_update_release(release, resp_update_release):
- release.name = release_name
- release.description = release_description
- release.save()
- assert release.name == release_name
- assert release.description == release_description