test: Option to make size check strict

Sometimes it's practical not just warn when ISO is larger than expected,
but to also abort the compose.

JIRA: COMPOSE-3658
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-07-15 09:25:26 +02:00
parent eeec62756f
commit 62c6d4ddcf
4 changed files with 59 additions and 2 deletions

View file

@ -181,6 +181,27 @@ class TestCheckImageSanity(PungiTestCase):
warnings,
)
@mock.patch("pungi.phases.test.check_sanity", new=mock.Mock())
def test_too_big_iso_strict(self):
compose = DummyCompose(
self.topdir,
{
"createiso_max_size": [(".*", {"*": 10})],
"createiso_max_size_is_strict": [(".*", {"*": True})],
},
)
compose.image.format = 'iso'
compose.image.bootable = False
compose.image.size = 20
with self.assertRaises(RuntimeError) as ctx:
test_phase.check_image_sanity(compose)
self.assertEqual(
str(ctx.exception),
"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_unified(self):
compose = DummyCompose(self.topdir, {})
@ -198,6 +219,26 @@ class TestCheckImageSanity(PungiTestCase):
warnings,
)
@mock.patch("pungi.phases.test.check_sanity", new=mock.Mock())
def test_too_big_unified_strict(self):
compose = DummyCompose(
self.topdir,
{"createiso_max_size_is_strict": [(".*", {"*": True})]},
)
compose.image.format = 'iso'
compose.image.bootable = False
compose.image.size = 20
compose.image.unified = True
setattr(compose.image, "_max_size", 10)
with self.assertRaises(RuntimeError) as ctx:
test_phase.check_image_sanity(compose)
self.assertEqual(
str(ctx.exception),
"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_fits_in_limit(self):
compose = DummyCompose(self.topdir, {"createiso_max_size": [(".*", {"*": 20})]})