Fix Koji search for modules with dash in stream

MBS replaces the dash by underscore. We have to match that.

Merges: https://pagure.io/pungi/pull-request/1005
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2018-07-18 10:22:33 +02:00 committed by Lubomír Sedlář
parent 23c454ff67
commit 6080b45178
2 changed files with 14 additions and 8 deletions

View File

@ -114,9 +114,15 @@ def get_koji_modules(compose, koji_wrapper, module_info_str):
module_info = variant_dict_from_str(compose, module_info_str)
# we need to format the query string to koji reguirements
query_str = "%s-%s-%s.%s" % (module_info["name"], module_info["stream"],
module_info.get("version", "*"), module_info.get("context", "*"))
# We need to format the query string to koji reguirements. The
# transformation to NVR for use in Koji has to match what MBS is doing when
# importing the build.
query_str = "%s-%s-%s.%s" % (
module_info["name"],
module_info["stream"].replace("-", "_"),
module_info.get("version", "*"),
module_info.get("context", "*"),
)
query_str = query_str.replace('*.*', '*')
koji_builds = koji_proxy.search(query_str, "build", "glob")

View File

@ -341,7 +341,7 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
self.assertEqual(pkgsets, expected)
def test_get_koji_modules(self):
mock_build_ids = [{'id': 1065873, 'name': 'testmodule2-master-20180406051653.96c371af'}]
mock_build_ids = [{'id': 1065873, 'name': 'testmodule2-master_dash-20180406051653.96c371af'}]
mock_extra = {
'typeinfo': {
'module': {
@ -355,10 +355,10 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
'epoch': None,
'extra': mock_extra,
'name': 'testmodule2',
'nvr': 'testmodule2-master-20180406051653.2e6f5e0a',
'nvr': 'testmodule2-master_dash-20180406051653.2e6f5e0a',
'release': '20180406051653.2e6f5e0a',
'state': 1,
'version': 'master',
'version': 'master_dash',
}
]
mock_archives = [
@ -392,7 +392,7 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
self.koji_wrapper.koji_proxy.listArchives.return_value = mock_archives
self.koji_wrapper.koji_proxy.listRPMs.return_value = mock_rpms
module_info_str = "testmodule2:master:20180406051653:96c371af"
module_info_str = "testmodule2:master-dash:20180406051653:96c371af"
result = source_koji.get_koji_modules(self.compose, self.koji_wrapper, module_info_str)
assert type(result) is list
@ -405,7 +405,7 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
assert "stream" in module
assert "context" in module
expected_query = "testmodule2-master-20180406051653.96c371af"
expected_query = "testmodule2-master_dash-20180406051653.96c371af"
self.koji_wrapper.koji_proxy.search.assert_called_once_with(expected_query, "build",
"glob")
self.koji_wrapper.koji_proxy.getBuild.assert_called_once_with(mock_build_ids[0]["id"])