diff --git a/tests/integration/test_buildrequire_module_not_in_tag.py b/tests/integration/test_buildrequire_invalid_module.py similarity index 51% rename from tests/integration/test_buildrequire_module_not_in_tag.py rename to tests/integration/test_buildrequire_invalid_module.py index 6a5b9a33..02d2bc7b 100644 --- a/tests/integration/test_buildrequire_module_not_in_tag.py +++ b/tests/integration/test_buildrequire_invalid_module.py @@ -4,7 +4,11 @@ import pytest from sh import ErrorReturnCode -def test_buildrequire_module_not_in_tag(pkg_util, scenario, repo, koji): +# expected error message +CANNOT_FIND_ANY_MODULE_BUILDS = "Cannot find any module builds" # ... + + +def test_buildrequire_invalid_module(pkg_util, scenario, repo, koji): """ Run a build with with an invalid 'build_require' module. I.e.: required module is picked in such a way, @@ -12,30 +16,30 @@ def test_buildrequire_module_not_in_tag(pkg_util, scenario, repo, koji): see platform's modulemd file and its 'koji_tag_with_modules' attribute (e.g.: platform: el-8.1.0 --> rhel-8.1.0-modules-build). - Koji resolver is expected to not be able to satisfy this build requirement and hence fail the build. + Koji resolver is expected to not be able to satisfy this build requirement + and hence fail the build. Assert that: - * the module build hasn't been accepted by MBS - rhpkg utility returns something else than 0 + * the module build hasn't been accepted by MBS: + rhpkg utility returns something else than 0 + * "Cannot find any module build..." found on STDERR If assert fails: - * cancel all triggered module builds + * cancel all triggered module builds. """ repo.bump() try: - builds = pkg_util.run( - "--optional", - "rebuild_strategy=all" - ) + builds = pkg_util.run("--optional", "rebuild_strategy=all") for build in builds: print("Canceling module-build {}...".format(build.id)) pkg_util.cancel(build) - pytest.fail("build_require satisfied and module build accepted by MBS!") + pytest.fail("Invalid 'build_require' was satisfied and module build was accepted by MBS!") except ErrorReturnCode as e: - # expected outcome is that build submission fails - pass + # expected outcome: build submission fails + assert CANNOT_FIND_ANY_MODULE_BUILDS in e.stderr.decode("utf-8") diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 480db8a9..7eb12b1c 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -167,7 +167,11 @@ class PackagingUtility: def __init__(self, packaging_utility, mbs_api): self._packaging_utility = Command(packaging_utility).bake( - _out=sys.stdout, _err=sys.stderr, _tee=True + # review: is redirect necessary? + # In case of failure, I can't find the stderr in the resulting exception object.. + #_out=sys.stdout, + #_err=sys.stderr, + _tee=True ) self._mbs_api = mbs_api