mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-06-15 06:27:00 +08:00
Fix --add-local-build with MBS Resolver.
The `MBSResolver.get_buildrequired_modulemds` did not try to load local module builds and always just queried the remote MBS instance. This commit fixes it by using local module if available.
This commit is contained in:
@@ -269,6 +269,12 @@ class MBSResolver(GenericResolver):
|
||||
:rtype: list
|
||||
:return: List of modulemd metadata.
|
||||
"""
|
||||
# If user used --add-local-build, we do actually not care about base_module_nsvc,
|
||||
# because the user directly asked us to use that module.
|
||||
local_modules = models.ModuleBuild.local_modules(self.db_session, name, stream)
|
||||
if local_modules:
|
||||
return [m.mmd() for m in local_modules]
|
||||
|
||||
modules = self._get_modules(name, stream, strict=False, base_module_br=base_module_nsvc)
|
||||
return [load_mmd(module["modulemd"]) for module in modules]
|
||||
|
||||
|
||||
@@ -451,3 +451,28 @@ class TestMBSModule:
|
||||
"virtual_stream": "virtualf28",
|
||||
},
|
||||
)
|
||||
|
||||
@patch(
|
||||
"module_build_service.config.Config.system", new_callable=PropertyMock, return_value="test"
|
||||
)
|
||||
@patch(
|
||||
"module_build_service.config.Config.mock_resultsdir",
|
||||
new_callable=PropertyMock,
|
||||
return_value=tests.staged_data_filename("local_builds")
|
||||
)
|
||||
def test_get_buildrequired_modulemds_local_builds(
|
||||
self, local_builds, conf_system, db_session
|
||||
):
|
||||
tests.clean_database()
|
||||
with tests.app.app_context():
|
||||
module_build_service.utils.load_local_builds(db_session, ["testmodule"])
|
||||
|
||||
resolver = mbs_resolver.GenericResolver.create(db_session, tests.conf, backend="mbs")
|
||||
result = resolver.get_buildrequired_modulemds(
|
||||
"testmodule", "master", "platform:f28:1:00000000")
|
||||
assert 1 == len(result)
|
||||
mmd = result[0]
|
||||
assert "testmodule" == mmd.get_module_name()
|
||||
assert "master" == mmd.get_stream_name()
|
||||
assert 20170816080816 == mmd.get_version()
|
||||
assert "321" == mmd.get_context()
|
||||
|
||||
Reference in New Issue
Block a user