Merge #1675 Don't traceback on failed builds

This commit is contained in:
Brendan Reilly
2022-05-19 18:30:20 +00:00
3 changed files with 21 additions and 16 deletions

View File

@@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import logging
from mock import patch
import pytest
@@ -205,14 +206,14 @@ class TestCommandBuildModuleLocally:
args, _ = logging.error.call_args_list[1]
assert "Use '-s module_name:module_stream' to choose the stream" == args[0]
def test_module_build_failed(self):
def test_module_build_failed(self, caplog):
cli_cmd = [
"mbs-manager", "build_module_locally",
"--set-stream", "platform:f28",
"--file", staged_data_filename("testmodule-local-build.yaml")
]
def main_side_effect(module_build_ids):
def init_side_effect(*args):
build = db_session.query(models.ModuleBuild).filter(
models.ModuleBuild.name == "testmodule-local-build"
).first()
@@ -222,7 +223,10 @@ class TestCommandBuildModuleLocally:
# We don't run consumer actually, but it could be patched to mark some
# module build failed for test purpose.
with patch("module_build_service.scheduler.local.main",
side_effect=main_side_effect):
with pytest.raises(RuntimeError, match="Module build failed"):
self._run_manager_wrapper(cli_cmd)
with patch("module_build_service.scheduler.local.modules_init_handler",
side_effect=init_side_effect):
self._run_manager_wrapper(cli_cmd)
r = [r for r in caplog.records if r.levelno == logging.ERROR
and "Local module build failed" in r.getMessage()]
assert len(r) > 0