From 294d664bb8d24a250daf3060cd94b18148002a8d Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 22 Feb 2023 15:15:23 +0100 Subject: [PATCH] WIP Add test for release_mixin --- test/test_release_mixin.py | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/test_release_mixin.py diff --git a/test/test_release_mixin.py b/test/test_release_mixin.py new file mode 100644 index 0000000..601f3fd --- /dev/null +++ b/test/test_release_mixin.py @@ -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() \ No newline at end of file