From 4e5f74b78def28790176a013177e2be6b1a2ca03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 31 May 2019 12:36:57 +0200 Subject: [PATCH] pkgset: Set correct nsvc for devel modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to update the source modulemd to match what we want. For most modules the name will be correct already, but in case of devel modules the original name will still be present there. Fixes: COMPOSE-3596 Signed-off-by: Lubomír Sedlář --- pungi/phases/pkgset/sources/source_koji.py | 3 +++ tests/test_pkgset_source_koji.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index 815576d7..a5bd001f 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -246,6 +246,9 @@ def _add_module_to_variant(koji_wrapper, variant, build, add_to_variant_modules= return source_mmd = mmds["modulemd.txt"] + # Set name from build to modulemd. Generally it will match, but for devel + # modules the source mmd contains the original name. + source_mmd.set_name(build["extra"]["typeinfo"]["module"]["name"]) nsvc = source_mmd.dup_nsvc() variant.mmds.append(source_mmd) diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index f86a8dcc..12568a32 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -671,6 +671,9 @@ class MockModule(object): def dup_nsvc(self): return "module:master:20190318.abcdef" + def set_name(self, name): + pass + @mock.patch("pungi.Modulemd.Module.new_from_file", new=MockModule) @unittest.skipIf(Modulemd is None, "Skipping tests, no module support") @@ -685,7 +688,7 @@ class TestAddModuleToVariant(unittest.TestCase): ] + [{"btype": "foo"}] def test_adding_module(self): - build = {"id": 1234} + build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}} variant = mock.Mock( arches=["armhfp", "x86_64"], mmds=[], arch_mmds={}, modules=[] ) @@ -707,7 +710,7 @@ class TestAddModuleToVariant(unittest.TestCase): self.assertEqual(variant.modules, []) def test_adding_module_to_existing(self): - build = {"id": 1234} + build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}} variant = mock.Mock( arches=["armhfp", "x86_64"], mmds=[MockModule("/koji/m1.txt")], @@ -737,7 +740,7 @@ class TestAddModuleToVariant(unittest.TestCase): self.assertEqual(variant.modules, ["m1:latest-20190101.cafe"]) def test_adding_module_with_add_module(self): - build = {"id": 1234} + build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}} variant = mock.Mock( arches=["armhfp", "x86_64"], mmds=[], arch_mmds={}, modules=[] ) @@ -761,7 +764,7 @@ class TestAddModuleToVariant(unittest.TestCase): self.assertEqual(variant.modules, ["module:master:20190318.abcdef"]) def test_adding_module_to_existing_with_add_module(self): - build = {"id": 1234} + build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}} variant = mock.Mock( arches=["armhfp", "x86_64"], mmds=[MockModule("/koji/m1.txt")],