Compare commits
3 commits
1e2593e358
...
99b8884d11
Author | SHA1 | Date | |
---|---|---|---|
99b8884d11 | |||
294d664bb8 | |||
d22dbbf050 |
3 changed files with 60 additions and 4 deletions
|
@ -5,6 +5,7 @@ from version import Version
|
|||
from version_repository import VersionRepository
|
||||
from services import InitReleaseService, PrepareReleaseService, TagAndPushReleaseService
|
||||
from git_repository import GitRepository
|
||||
from release_type import ReleaseType
|
||||
|
||||
def create_release_mixin_config(config_file, main_branch) -> dict:
|
||||
config = {}
|
||||
|
@ -35,7 +36,6 @@ class ReleaseMixin(DevopsBuild):
|
|||
init_service = InitReleaseService(self.version_repo)
|
||||
self.release_version = init_service.create_release_version()
|
||||
self.bump_version = self.release_version.create_bump_version()
|
||||
return self.release_version, self.bump_version
|
||||
|
||||
def prepare(self, version):
|
||||
git_repository = GitRepository()
|
||||
|
|
|
@ -32,9 +32,9 @@ class InitReleaseService():
|
|||
|
||||
class PrepareReleaseService():
|
||||
|
||||
def __init__(self):
|
||||
self.version_repo
|
||||
pass
|
||||
def __init__(self, version_repo: VersionRepository):
|
||||
self.version_repo = version_repo
|
||||
|
||||
|
||||
def run_tests(self): # maybe auto?
|
||||
pass
|
||||
|
|
56
test/test_release_mixin.py
Normal file
56
test/test_release_mixin.py
Normal file
|
@ -0,0 +1,56 @@
|
|||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
from ddadevops import *
|
||||
|
||||
# getting the name of the directory
|
||||
# where the this file is present.
|
||||
current = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# Getting the parent directory name
|
||||
# where the current directory is present.
|
||||
parent = os.path.dirname(current)
|
||||
|
||||
# adding the parent directory to
|
||||
# the sys.path.
|
||||
sys.path.append(parent)
|
||||
|
||||
# now we can import the module in the parent
|
||||
# directory.
|
||||
|
||||
from pybuilder.core import task, init, Project
|
||||
from version import *
|
||||
from release_mixin import ReleaseMixin, create_release_mixin_config
|
||||
|
||||
MAIN_BRANCH = 'main'
|
||||
|
||||
|
||||
class MyBuild(ReleaseMixin):
|
||||
pass
|
||||
|
||||
def initialize(project, CONFIG_FILE):
|
||||
project.build_depends_on('ddadevops>=3.1.2')
|
||||
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH)
|
||||
build = MyBuild(project, config)
|
||||
return build
|
||||
|
||||
def test_release_mixin(tmp_path):
|
||||
|
||||
with open(f'test/resources/config.json', 'r') as json_file:
|
||||
contents = json_file.read()
|
||||
|
||||
CONFIG_FILE = tmp_path / "config.json"
|
||||
CONFIG_FILE.write_text(contents)
|
||||
|
||||
base_dir = "."
|
||||
project = Project(base_dir)
|
||||
|
||||
# init
|
||||
build = initialize(project, CONFIG_FILE)
|
||||
build.init()
|
||||
release_version = build.release_version
|
||||
bump_version = build.bump_version
|
||||
|
||||
# test
|
||||
assert "123.124.0" in release_version.get_version_string()
|
||||
assert "123.124.1-SNAPSHOT" in bump_version.get_version_string()
|
Loading…
Reference in a new issue