Add mock API
This commit is contained in:
parent
0617348e84
commit
07abf81bda
3 changed files with 144 additions and 0 deletions
47
src/main/python/ddadevops/release-mixin/test/mock_domain.py
Normal file
47
src/main/python/ddadevops/release-mixin/test/mock_domain.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
current = os.path.dirname(os.path.realpath(__file__))
|
||||
parent = os.path.dirname(current)
|
||||
sys.path.append(parent)
|
||||
|
||||
from domain import ReleaseType
|
||||
|
||||
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
|
||||
|
||||
def release_version(self):
|
||||
return MockVersion()
|
||||
|
||||
def bump_version(self):
|
||||
return MockVersion()
|
||||
|
||||
def validate(self, main_branch):
|
||||
self.validate_count =+ 1
|
||||
return self.is_valid
|
||||
|
||||
def is_valid(self, main_branch):
|
||||
return True
|
|
@ -0,0 +1,46 @@
|
|||
import os
|
||||
import sys
|
||||
from mock_domain import MockRelease, MockVersion
|
||||
from mock_infrastructure_api import MockGitApi
|
||||
|
||||
current = os.path.dirname(os.path.realpath(__file__))
|
||||
parent = os.path.dirname(current)
|
||||
sys.path.append(parent)
|
||||
|
||||
from domain import ReleaseType
|
||||
|
||||
class MockVersionRepository():
|
||||
|
||||
def __init__(self):
|
||||
self.file = None
|
||||
self.file_handler = None
|
||||
|
||||
def load_file(self):
|
||||
pass
|
||||
|
||||
def write_file(self, version_string):
|
||||
self.write_file_count =+ 1
|
||||
pass
|
||||
|
||||
def parse_file(self):
|
||||
pass
|
||||
|
||||
def get_version(self) -> MockVersion:
|
||||
return MockVersion()
|
||||
|
||||
class MockReleaseTypeRepository():
|
||||
def __init__(self, mock_git_api: MockGitApi):
|
||||
self.git_api = mock_git_api
|
||||
|
||||
def get_release_type(self):
|
||||
return ReleaseType.MINOR
|
||||
|
||||
class MockReleaseRepository():
|
||||
def __init__(self, version_repository: MockVersionRepository, release_type_repository: MockReleaseTypeRepository, main_branch: str):
|
||||
self.version_repository = version_repository
|
||||
self.release_type_repository = release_type_repository
|
||||
self.main_branch = main_branch
|
||||
|
||||
def get_release(self) -> MockRelease:
|
||||
self.get_release_count =+ 1
|
||||
return MockRelease(self.release_type_repository.get_release_type(), self.version_repository.get_version(), self.main_branch)
|
|
@ -0,0 +1,51 @@
|
|||
class MockSystemAPI():
|
||||
|
||||
def __init__(self):
|
||||
self.stdout = [""]
|
||||
self.stderr = [""]
|
||||
|
||||
def run(self, args):
|
||||
pass
|
||||
|
||||
def run_checked(self, *args):
|
||||
self.run(args)
|
||||
pass
|
||||
|
||||
class MockGitApi():
|
||||
|
||||
def __init__(self):
|
||||
self.system_api = MockSystemAPI()
|
||||
|
||||
def get_latest_n_commits(self, n: int):
|
||||
return " "
|
||||
|
||||
def get_latest_commit(self):
|
||||
return " "
|
||||
|
||||
def tag_annotated(self, annotation: str, message: str, count: int):
|
||||
self.tag_annotated_count =+ 1
|
||||
return " "
|
||||
|
||||
def get_latest_tag(self):
|
||||
return " "
|
||||
|
||||
def get_current_branch(self):
|
||||
return " "
|
||||
|
||||
def init(self):
|
||||
pass
|
||||
|
||||
def add_file(self, file_path):
|
||||
self.add_file_count =+ 1
|
||||
return " "
|
||||
|
||||
def commit(self, commit_message: str):
|
||||
self.commit_count =+ 1
|
||||
return commit_message
|
||||
|
||||
def push(self):
|
||||
self.push_count =+ 1
|
||||
return " "
|
||||
|
||||
def checkout(self, branch: str):
|
||||
return " "
|
Loading…
Reference in a new issue