diff --git a/tests/staged_data/platform.yaml b/tests/staged_data/platform.yaml index 4d364f2a..1b878c92 100644 --- a/tests/staged_data/platform.yaml +++ b/tests/staged_data/platform.yaml @@ -24,3 +24,4 @@ data: requires: {} mse: true koji_tag: module-f28-build + koji_side_tag_format: module-f28-{side_tag}-build diff --git a/tests/test_resolver/test_db.py b/tests/test_resolver/test_db.py index 979fe266..1a82b8ef 100644 --- a/tests/test_resolver/test_db.py +++ b/tests/test_resolver/test_db.py @@ -99,6 +99,33 @@ class TestDBModule: "testmodule", "master", "20170109091357", "78e4a6fd").keys() assert set(result) == expected + @pytest.mark.parametrize("missing_format", [False, True]) + def test_get_module_build_dependencies_side_tag( + self, missing_format, reuse_component_init_data): + """ + Test that we get the correct base module tag when a side tag is specified + """ + platform = models.ModuleBuild.get_by_id(db_session, 1) + module = models.ModuleBuild.get_by_id(db_session, 2) + mmd = module.mmd() + xmd = mmd.get_xmd() + side_tag = "SIDETAG" + expected = {"module-f28-SIDETAG-build"} + xmd["mbs"]["side_tag"] = side_tag + mmd.set_xmd(xmd) + if missing_format: + # remove koji_tag_format from our platform + platform_mmd = platform.mmd() + platform_xmd = platform_mmd.get_xmd() + del platform_xmd["mbs"]["koji_side_tag_format"] + platform_mmd.set_xmd(platform_xmd) + platform.modulemd = mmd_to_str(mmd) + db_session.commit() + expected = {"module-f28-build"} + resolver = mbs_resolver.GenericResolver.create(db_session, conf, backend="db") + result = resolver.get_module_build_dependencies(mmd=mmd).keys() + assert set(result) == expected + def test_get_module_build_dependencies_recursive(self, reuse_component_init_data): """ Tests that the buildrequires are returned when it is two layers deep diff --git a/tests/test_web/test_submit.py b/tests/test_web/test_submit.py index 8a75bf53..633b8160 100644 --- a/tests/test_web/test_submit.py +++ b/tests/test_web/test_submit.py @@ -17,7 +17,7 @@ from module_build_service.common.utils import (mmd_to_str, load_mmd, from module_build_service.scheduler.db_session import db_session from module_build_service.web.submit import ( get_prefixed_version, submit_module_build, submit_module_build_from_yaml, - process_module_context_configuration + process_module_context_configuration, _apply_side_tag, ) from tests import ( scheduler_init_data, @@ -218,6 +218,53 @@ class TestProcessModuleContextConfiguration: assert stream.is_static_context() +class TestApplySideTag: + def get_mmd(self): + yaml_str = """ +document: modulemd +version: 2 +data: + name: app + stream: test + summary: "A test module" + description: > + "A test module stream" + license: + module: [ MIT ] + dependencies: + - buildrequires: + platform: [] + gtk: [] + requires: + platform: [] + gtk: [] + """ + return load_mmd(yaml_str) + + def test_apply_side_tag(self): + """ + Test that the side tag option is correctly added into the xmd + """ + mmd = self.get_mmd() + side_tag = "SIDETAG" + _apply_side_tag(mmd, {"side_tag": side_tag}) + + xmd = mmd.get_xmd() + assert xmd["mbs"]["side_tag"] == side_tag + + def test_apply_side_tag_no_option(self): + """ + Test that the xmd is unchanged when option not given + """ + mmd = self.get_mmd() + xmd_orig = mmd.get_xmd() + _apply_side_tag(mmd, {}) + + xmd = mmd.get_xmd() + assert xmd == xmd_orig + assert "side_tag" not in xmd.get("mbs", {}) + + @pytest.mark.usefixtures("reuse_component_init_data") class TestUtilsComponentReuse: @mock.patch("module_build_service.web.submit.submit_module_build")