Add better assert, remove stdout/err redirect

This commit is contained in:
jobrauer
2020-02-17 13:29:03 +01:00
parent e94dee5c50
commit cdd0dcbb37
2 changed files with 20 additions and 12 deletions

View File

@@ -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")

View File

@@ -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