From e501525db24b542d3ae109d5903f87cb72cb8bd4 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Apr 2023 18:13:45 +0200 Subject: [PATCH] fix tests --- src/test/python/domain/test_domain.py | 48 ++++++++++++++++----------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/test/python/domain/test_domain.py b/src/test/python/domain/test_domain.py index 230e130..bee073d 100644 --- a/src/test/python/domain/test_domain.py +++ b/src/test/python/domain/test_domain.py @@ -5,10 +5,16 @@ from src.main.python.ddadevops.domain.common import ( DnsRecord, Devops, ) -from src.main.python.ddadevops.domain import Version, ReleaseType, Release, ReleaseContext +from src.main.python.ddadevops.domain import ( + Version, + ReleaseType, + Release, + ReleaseContext, +) from src.main.python.ddadevops.domain.image import Image from src.main.python.ddadevops.domain.c4k import C4k from src.main.python.ddadevops.c4k_mixin import add_c4k_mixin_config +from .test_helper import build_devops class MockValidateable(Validateable): @@ -62,6 +68,7 @@ def test_should_validate_DnsRecord(): sut = DnsRecord("name", ipv6="1::") assert sut.is_valid() + def test_c4k_build_should_update_fqdn(): project_config = { "stage": "test", @@ -108,7 +115,9 @@ def test_c4k_build_should_update_fqdn(): def test_c4k_build_should_calculate_command(): - devops = Devops(stage="test", project_root_path="", module="module", name="name") + devops = build_devops( + {"project_root_path": ".", "module": "module", "name": "name"} + ) project_config = { "stage": "test", "name": "name", @@ -126,9 +135,9 @@ def test_c4k_build_should_calculate_command(): sut = C4k(project_config) assert ( "c4k-module-standalone.jar " - + "/target/name/module/out_c4k_config.yaml " - + "/target/name/module/out_c4k_auth.yaml > " - + "/target/name/module/out_module.yaml" + + "./target/name/module/out_c4k_config.yaml " + + "./target/name/module/out_c4k_auth.yaml > " + + "./target/name/module/out_module.yaml" == sut.command(devops) ) @@ -150,12 +159,13 @@ def test_c4k_build_should_calculate_command(): sut = C4k(project_config) assert ( "c4k-executabel_name-standalone.jar " - + "/target/name/module/out_c4k_config.yaml " - + "/target/name/module/out_c4k_auth.yaml > " - + "/target/name/module/out_module.yaml" + + "./target/name/module/out_c4k_config.yaml " + + "./target/name/module/out_c4k_auth.yaml > " + + "./target/name/module/out_module.yaml" == sut.command(devops) ) + def test_version(tmp_path: Path): version = Version(tmp_path, [1, 2, 3]) version.increment(ReleaseType.SNAPSHOT) @@ -187,31 +197,29 @@ def test_version(tmp_path: Path): assert version.version_list == [2, 0, 0] assert not version.is_snapshot + def test_release_context(tmp_path): version = Version(tmp_path, [1, 2, 3]) release = ReleaseContext(ReleaseType.MINOR, version, "main") release_version = release.release_version() - assert release_version.get_version_string() in '1.3.0' + assert release_version.get_version_string() in "1.3.0" bump_version = release.bump_version() assert bump_version.get_version_string() in "1.3.1-SNAPSHOT" + def test_release(tmp_path): - devops = Devops(stage="test", project_root_path="", module="module", name="name") + devops = build_devops({}) sut = Release(devops, "main", "config_file.json") assert not sut.is_valid() - sut.set_release_context(ReleaseContext(ReleaseType.MINOR, Version("id", [1,2,3]), "main")) + sut.set_release_context( + ReleaseContext(ReleaseType.MINOR, Version("id", [1, 2, 3]), "main") + ) assert sut.is_valid() + def test_devops_build_commons_path(): - devops = Devops( - stage="test", project_root_path="../../..", module="cloud", name="meissa" - ) - sut = Image( - dockerhub_user="user", - dockerhub_password="password", - devops = devops, - ) - assert "docker/" == sut.docker_build_commons_path() + sut = build_devops({}) + assert "docker/" == sut.specialized_build.docker_build_commons_path()