Stop mocking domain objects

Resolves 1 TODO
This commit is contained in:
bom 2023-04-27 15:01:07 +02:00
parent 35465b543b
commit a28a1b43d3
2 changed files with 7 additions and 49 deletions

View file

@ -1,43 +0,0 @@
from src.main.python.ddadevops.domain import ReleaseType
# TODO: Domain never should be needed to mock! Why do you not yust create the needed object?
class MockVersion():
def __init__(self, id = None, version_list = None):
self.id = None
self.version_list = None
self.version_string = None
self.is_snapshot = None
def increment(self, release_type: ReleaseType):
pass
def get_version_string(self) -> str:
return ""
def create_release_version(self, release_type: ReleaseType):
return MockVersion()
def create_bump_version(self):
return MockVersion()
class MockRelease():
def __init__(self, release_type, version, current_branch):
self.release_type = release_type
self.version = version
self.current_branch = current_branch
self.validate_count = 0
def release_version(self):
return self.version.create_release_version(self.release_type)
def bump_version(self):
return self.release_version().create_bump_version()
def validate(self):
self.validate_count += 1
return []
def is_valid(self):
return len(self.validate()) < 1

View file

@ -1,6 +1,7 @@
from src.main.python.ddadevops.domain import ReleaseType from pathlib import Path
from src.main.python.ddadevops.domain import ReleaseType, Version, ReleaseContext
from .mock_domain import MockRelease, MockVersion
from .mock_infrastructure_api import MockGitApi from .mock_infrastructure_api import MockGitApi
class MockVersionRepository(): class MockVersionRepository():
@ -20,8 +21,8 @@ class MockVersionRepository():
def parse_file(self): def parse_file(self):
pass pass
def get_version(self) -> MockVersion: def get_version(self) -> Version:
return MockVersion() return Version(Path(), [0,0,0])
class MockReleaseTypeRepository(): class MockReleaseTypeRepository():
def __init__(self, mock_git_api: MockGitApi): def __init__(self, mock_git_api: MockGitApi):
@ -37,6 +38,6 @@ class MockReleaseRepository():
self.main_branch = main_branch self.main_branch = main_branch
self.get_release_count = 0 self.get_release_count = 0
def get_release(self) -> MockRelease: def get_release(self) -> ReleaseContext:
self.get_release_count += 1 self.get_release_count += 1
return MockRelease(self.release_type_repository.get_release_type(), self.version_repository.get_version(), self.main_branch) return ReleaseContext(self.release_type_repository.get_release_type(), self.version_repository.get_version(), self.main_branch)