From caaf804fd32f643e687453170930c1e93bd5a886 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Mon, 14 Aug 2023 09:15:46 +0200 Subject: [PATCH] add release-endpoint-calculation to domain object --- src/main/python/ddadevops/domain/release.py | 5 ++++- src/test/python/domain/test_release.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/python/ddadevops/domain/release.py b/src/main/python/ddadevops/domain/release.py index 29f78c1..f3516cd 100644 --- a/src/main/python/ddadevops/domain/release.py +++ b/src/main/python/ddadevops/domain/release.py @@ -77,7 +77,7 @@ class Release(Validateable): result += self.release_secondary_build_files return result - def forgejo_release_api_endpoint(self): + def forgejo_release_api_endpoint(self) -> str: validation = self.validate_for_artifact() if validation != []: raise RuntimeError(f"not valid for creating artifacts: {validation}") @@ -89,6 +89,9 @@ class Release(Validateable): repository = self.release_repository_name.removeprefix("/").removesuffix("/") return f"{server_url}/api/v1/repos/{organisation}/{repository}/releases" + def forgejo_release_asset_api_endpoint(self, id: int) -> str: + return f"{self.forgejo_release_api_endpoint()}/{id}/assets" + @classmethod def get_mapping_default(cls) -> List[Dict[str, str]]: return [ diff --git a/src/test/python/domain/test_release.py b/src/test/python/domain/test_release.py index 42f8699..efa82a6 100644 --- a/src/test/python/domain/test_release.py +++ b/src/test/python/domain/test_release.py @@ -115,3 +115,21 @@ def test_should_calculate_forgejo_release_api_endpoint(): Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"), ) sut.forgejo_release_api_endpoint() + +def test_should_calculate_forgejo_release_asset_api_endpoint(): + sut = Release( + devops_config( + { + "release_artifacts": ["x"], + "release_artifact_token": "y", + "release_artifact_server_url": "https://repo.prod.meissa.de", + "release_organisation": "meissa", + "release_repository_name": "provs", + } + ), + Version.from_str("1.3.1-SNAPSHOT", "SNAPSHOT"), + ) + assert ( + "https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases/123/assets" + == sut.forgejo_release_asset_api_endpoint(123) + )