Use EnvironmentKeys, refactor in test accordingly

This commit is contained in:
erik 2023-04-11 16:16:08 +02:00
parent f51afe8bbc
commit 3776116383
2 changed files with 9 additions and 9 deletions

View file

@ -1,4 +1,4 @@
from .domain import Release, Version, ReleaseType
from .domain import Release, Version, ReleaseType, EnvironmentKeys
from .infrastructure_api import FileHandler, GitApi, EnvironmentApi
class VersionRepository():
@ -60,7 +60,7 @@ class ReleaseTypeRepository():
return None
def __get_release_type_environment(self) -> ReleaseType | None:
release_name = self.environment_api.get('RELEASE_TYPE')
release_name = self.environment_api.get(EnvironmentKeys.DDADEVOPS_RELEASE_TYPE.name)
if release_name is None:
return None

View file

@ -54,27 +54,27 @@ def test_release_type_repository_git():
assert release_type == None
def test_release_type_repository_env():
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'RELEASE_TYPE': 'MINOR test'}))
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'DDADEVOPS_RELEASE_TYPE': 'MINOR test'}))
release_type = sut.get_release_type()
assert release_type is ReleaseType.MINOR
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'RELEASE_TYPE': 'MINOR'}))
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'DDADEVOPS_RELEASE_TYPE': 'MINOR'}))
release_type = sut.get_release_type()
assert release_type is ReleaseType.MINOR
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'RELEASE_TYPE': 'Major bla'}))
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'DDADEVOPS_RELEASE_TYPE': 'Major bla'}))
release_type = sut.get_release_type()
assert release_type == ReleaseType.MAJOR
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'RELEASE_TYPE': 'Patch bla'}))
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'DDADEVOPS_RELEASE_TYPE': 'Patch bla'}))
release_type = sut.get_release_type()
assert release_type == ReleaseType.PATCH
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'RELEASE_TYPE': 'Snapshot bla'}))
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'DDADEVOPS_RELEASE_TYPE': 'Snapshot bla'}))
release_type = sut.get_release_type()
assert release_type == ReleaseType.SNAPSHOT
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'RELEASE_TYPE': 'Random text'}))
sut = ReleaseTypeRepository.from_environment(MockEnvironmentApi({'DDADEVOPS_RELEASE_TYPE': 'Random text'}))
release_type = sut.get_release_type()
assert release_type == None