pkgset: Set correct nsvc for devel modules

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ář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-05-31 12:36:57 +02:00
parent f6162b90dd
commit 4e5f74b78d
2 changed files with 10 additions and 4 deletions

View File

@ -246,6 +246,9 @@ def _add_module_to_variant(koji_wrapper, variant, build, add_to_variant_modules=
return return
source_mmd = mmds["modulemd.txt"] 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() nsvc = source_mmd.dup_nsvc()
variant.mmds.append(source_mmd) variant.mmds.append(source_mmd)

View File

@ -671,6 +671,9 @@ class MockModule(object):
def dup_nsvc(self): def dup_nsvc(self):
return "module:master:20190318.abcdef" return "module:master:20190318.abcdef"
def set_name(self, name):
pass
@mock.patch("pungi.Modulemd.Module.new_from_file", new=MockModule) @mock.patch("pungi.Modulemd.Module.new_from_file", new=MockModule)
@unittest.skipIf(Modulemd is None, "Skipping tests, no module support") @unittest.skipIf(Modulemd is None, "Skipping tests, no module support")
@ -685,7 +688,7 @@ class TestAddModuleToVariant(unittest.TestCase):
] + [{"btype": "foo"}] ] + [{"btype": "foo"}]
def test_adding_module(self): def test_adding_module(self):
build = {"id": 1234} build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}}
variant = mock.Mock( variant = mock.Mock(
arches=["armhfp", "x86_64"], mmds=[], arch_mmds={}, modules=[] arches=["armhfp", "x86_64"], mmds=[], arch_mmds={}, modules=[]
) )
@ -707,7 +710,7 @@ class TestAddModuleToVariant(unittest.TestCase):
self.assertEqual(variant.modules, []) self.assertEqual(variant.modules, [])
def test_adding_module_to_existing(self): def test_adding_module_to_existing(self):
build = {"id": 1234} build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}}
variant = mock.Mock( variant = mock.Mock(
arches=["armhfp", "x86_64"], arches=["armhfp", "x86_64"],
mmds=[MockModule("/koji/m1.txt")], mmds=[MockModule("/koji/m1.txt")],
@ -737,7 +740,7 @@ class TestAddModuleToVariant(unittest.TestCase):
self.assertEqual(variant.modules, ["m1:latest-20190101.cafe"]) self.assertEqual(variant.modules, ["m1:latest-20190101.cafe"])
def test_adding_module_with_add_module(self): def test_adding_module_with_add_module(self):
build = {"id": 1234} build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}}
variant = mock.Mock( variant = mock.Mock(
arches=["armhfp", "x86_64"], mmds=[], arch_mmds={}, modules=[] arches=["armhfp", "x86_64"], mmds=[], arch_mmds={}, modules=[]
) )
@ -761,7 +764,7 @@ class TestAddModuleToVariant(unittest.TestCase):
self.assertEqual(variant.modules, ["module:master:20190318.abcdef"]) self.assertEqual(variant.modules, ["module:master:20190318.abcdef"])
def test_adding_module_to_existing_with_add_module(self): def test_adding_module_to_existing_with_add_module(self):
build = {"id": 1234} build = {"id": 1234, "extra": {"typeinfo": {"module": {"name": "module"}}}}
variant = mock.Mock( variant = mock.Mock(
arches=["armhfp", "x86_64"], arches=["armhfp", "x86_64"],
mmds=[MockModule("/koji/m1.txt")], mmds=[MockModule("/koji/m1.txt")],