From f858cea4663af9981012f1a47768339f9e4906f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 30 Apr 2019 12:22:13 +0200 Subject: [PATCH] pkgset: Do not overwrite version in module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This value is important to get correct path to metadata. JIRA: COMPOSE-3541 Signed-off-by: Lubomír Sedlář --- pungi/phases/pkgset/sources/source_koji.py | 22 ++++++++++++---------- tests/test_pkgset_source_koji.py | 13 +++++++------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index 25e02765..2e305397 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -143,14 +143,12 @@ def get_koji_modules(compose, koji_wrapper, event, module_info_str): continue try: - md["modulemd"] = md["extra"]["typeinfo"]["module"]["modulemd_str"] md["tag"] = md["extra"]["typeinfo"]["module"]["content_koji_tag"] - # Get the NSVC from module metadata, because the original Koji build - # has '-' replaced with "_". - md["name"] = md["extra"]["typeinfo"]["module"]["name"] - md["stream"] = md["extra"]["typeinfo"]["module"]["stream"] - md["version"] = md["extra"]["typeinfo"]["module"]["version"] - md["context"] = md["extra"]["typeinfo"]["module"]["context"] + # Store module versioning information into the dict, but make sure + # not to overwrite any existing keys. + md["module_stream"] = md["extra"]["typeinfo"]["module"]["stream"] + md["module_version"] = int(md["extra"]["typeinfo"]["module"]["version"]) + md["module_context"] = md["extra"]["typeinfo"]["module"]["context"] except KeyError: continue @@ -167,9 +165,13 @@ def get_koji_modules(compose, koji_wrapper, event, module_info_str): # include all modules with that version. if not module_info.get('version'): # select all found modules with latest version - sorted_modules = sorted(modules, key=lambda item: int(item['version']), reverse=True) - latest_version = int(sorted_modules[0]['version']) - modules = [module for module in modules if latest_version == int(module['version'])] + sorted_modules = sorted( + modules, key=lambda item: item["module_version"], reverse=True + ) + latest_version = sorted_modules[0]["module_version"] + modules = [ + module for module in modules if latest_version == module["module_version"] + ] return modules diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index 8ea2df62..6d328a9e 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -303,9 +303,10 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase): assert len(result) == 1 module = result[0] assert type(module) is dict - assert "modulemd" in module - assert "stream" in module - assert "context" in module + self.assertIn("module_stream", module) + self.assertIn("module_version", module) + self.assertIn("module_context", module) + self.assertIn("tag", module) expected_query = "testmodule2-master_dash-20180406051653.96c371af" self.koji_wrapper.koji_proxy.search.assert_called_once_with(expected_query, "build", @@ -426,9 +427,9 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase): module = result[0] for module in result: assert type(module) is dict - assert "modulemd" in module - assert "stream" in module - assert "context" in module + self.assertIn("module_stream", module) + self.assertIn("module_version", module) + self.assertIn("module_context", module) expected_query = "testmodule2-master-*" self.koji_wrapper.koji_proxy.search.assert_called_once_with(expected_query, "build",