Enable release mixin test

This commit is contained in:
erik 2023-03-09 14:26:30 +01:00
parent 4098d00409
commit 5d2bbb758c

View file

@ -1,15 +1,17 @@
import sys
import os
import pytest as pt
from helper import Helper
from pathlib import Path
from ddadevops import *
from pybuilder.core import Project
current = os.path.dirname(os.path.realpath(__file__))
parent = os.path.dirname(current)
sys.path.append(parent)
from pybuilder.core import task, init, Project
from release_mixin import ReleaseMixin, create_release_mixin_config
from infrastructure_api import GitApi
MAIN_BRANCH = 'main'
STAGE = 'test'
@ -17,6 +19,9 @@ PROJECT_ROOT_PATH = '.'
MODULE = 'test'
BUILD_DIR_NAME = "build_dir"
def change_test_dir( tmp_path: Path, monkeypatch: pt.MonkeyPatch):
monkeypatch.chdir(tmp_path)
class MyBuild(ReleaseMixin):
pass
@ -30,29 +35,24 @@ def initialize(project, CONFIG_FILE):
build = MyBuild(project, config)
return build
#def test_release_mixin(tmp_path):
#
# #init
# 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.commit_string = "MAJOR bla"
# build.init_release()
# release_version = build.release_version
#
# # test
# assert "124.0.0" in release_version.get_version_string()
#
# # init
# bump_version = build.bump_version
#
# # test
# assert "124.0.1-SNAPSHOT" in bump_version.get_version_string()
def test_release_mixin(tmp_path: Path, monkeypatch: pt.MonkeyPatch):
# init
th = Helper()
th.copy_files(th.TEST_FILE_PATH, tmp_path)
th.TEST_FILE_PATH = tmp_path / th.TEST_FILE_NAME
change_test_dir(tmp_path, monkeypatch)
project = Project(tmp_path)
git_api = GitApi()
git_api.init()
git_api.add_file(th.TEST_FILE_NAME)
git_api.commit("MAJOR release")
build = initialize(project, th.TEST_FILE_PATH)
build.prepare_release()
release_version = build.version_repo.get_version()
# test
assert "124.0.1-SNAPSHOT" in release_version.get_version_string()