test: Allow turning strictness off as well

When the value is explicitly set to `False`, the check should not be
strict.

JIRA: COMPOSE-3658
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-07-16 08:22:28 +02:00
parent 61e3cb0ef1
commit 3097019338
3 changed files with 24 additions and 1 deletions

View File

@ -1092,6 +1092,8 @@ Options
**createiso_max_size_is_strict** **createiso_max_size_is_strict**
(*list*) -- Set the value to ``True`` to turn the warning from (*list*) -- Set the value to ``True`` to turn the warning from
``createiso_max_size`` into a hard error that will abort the compose. ``createiso_max_size`` into a hard error that will abort the compose.
If there are multiple matches in the mapping, the check will be strict if
at least one match says so.
Format: ``[(variant_uid_regex, {arch|*: bool})]`` Format: ``[(variant_uid_regex, {arch|*: bool})]``

View File

@ -182,7 +182,7 @@ def check_size_limit(compose, variant, arch, img):
msg = "ISO %s is too big. Expected max %dB, got %dB" % ( msg = "ISO %s is too big. Expected max %dB, got %dB" % (
img.path, limit, img.size img.path, limit, img.size
) )
if is_strict: if any(is_strict):
raise RuntimeError(msg) raise RuntimeError(msg)
else: else:
compose.log_warning(msg) compose.log_warning(msg)

View File

@ -202,6 +202,27 @@ class TestCheckImageSanity(PungiTestCase):
"ISO Client/i386/iso/image.iso is too big. Expected max 10B, got 20B", "ISO Client/i386/iso/image.iso is too big. Expected max 10B, got 20B",
) )
@mock.patch("pungi.phases.test.check_sanity", new=mock.Mock())
def test_too_big_iso_not_strict(self):
compose = DummyCompose(
self.topdir,
{
"createiso_max_size": [(".*", {"*": 10})],
"createiso_max_size_is_strict": [(".*", {"*": False})],
},
)
compose.image.format = 'iso'
compose.image.bootable = False
compose.image.size = 20
test_phase.check_image_sanity(compose)
warnings = [call[0][0] for call in compose.log_warning.call_args_list]
self.assertIn(
"ISO Client/i386/iso/image.iso is too big. Expected max 10B, got 20B",
warnings,
)
@mock.patch("pungi.phases.test.check_sanity", new=mock.Mock()) @mock.patch("pungi.phases.test.check_sanity", new=mock.Mock())
def test_too_big_unified(self): def test_too_big_unified(self):
compose = DummyCompose(self.topdir, {}) compose = DummyCompose(self.topdir, {})