Use EnvironmentKeys, refactor in test accordingly
This commit is contained in:
parent
f51afe8bbc
commit
3776116383
2 changed files with 9 additions and 9 deletions
|
@ -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():
|
||||
|
@ -33,7 +33,7 @@ class VersionRepository():
|
|||
class ReleaseTypeRepository():
|
||||
def __init__(self, git_api: GitApi, environment_api: EnvironmentApi):
|
||||
self.git_api = git_api
|
||||
self.environment_api = environment_api
|
||||
self.environment_api = environment_api
|
||||
|
||||
@classmethod
|
||||
def from_git(cls, git_api: GitApi):
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue