Merge #325 Fix checking optional ISO images in test phase

This commit is contained in:
Dennis Gilmore 2016-06-06 11:56:51 +00:00
commit 6800501217
3 changed files with 29 additions and 6 deletions

View File

@ -110,11 +110,14 @@ def check_image_sanity(compose):
manifest and logged. Otherwise the compose will be aborted. manifest and logged. Otherwise the compose will be aborted.
""" """
im = compose.im im = compose.im
for variant_uid in im.images: for variant in compose.get_variants():
variant = compose.variants[variant_uid] if variant.uid not in im.images:
for arch in im.images[variant_uid]: continue
images = im.images[variant_uid][arch] for arch in variant.arches:
im.images[variant_uid][arch] = [img for img in images if arch not in im.images[variant.uid]:
continue
images = im.images[variant.uid][arch]
im.images[variant.uid][arch] = [img for img in images
if check(compose, variant, arch, img)] if check(compose, variant, arch, img)]

View File

@ -63,7 +63,7 @@ class DummyCompose(object):
self.log_warning = mock.Mock() self.log_warning = mock.Mock()
self.get_image_name = mock.Mock(return_value='image-name') self.get_image_name = mock.Mock(return_value='image-name')
self.image = mock.Mock(path='Client/i386/iso/image.iso') self.image = mock.Mock(path='Client/i386/iso/image.iso')
self.im = mock.Mock(images={'Client': {'i386': [self.image]}}) self.im = mock.Mock(images={'Client': {'amd64': [self.image]}})
self.old_composes = [] self.old_composes = []
self.config_dir = '/home/releng/config' self.config_dir = '/home/releng/config'
self.notifier = None self.notifier = None

View File

@ -7,6 +7,7 @@ try:
except ImportError: except ImportError:
import unittest import unittest
import mock
import os import os
import sys import sys
@ -124,6 +125,25 @@ class TestCheckImageSanity(PungiTestCase):
except: except:
self.fail('Bootable image with MBR and GPT must not raise') self.fail('Bootable image with MBR and GPT must not raise')
def test_checks_with_optional_variant(self):
compose = DummyCompose(self.topdir, {})
compose.variants['Server'].variants = {
'optional': mock.Mock(uid='Server-optional', arches=['x86_64'],
type='optional', is_empty=False)
}
compose.image.format = 'iso'
compose.image.bootable = True
touch(os.path.join(self.topdir, 'compose', compose.image.path), ISO_WITH_MBR_AND_GPT)
image = mock.Mock(path="Server/i386/optional/iso/image.iso",
format='iso', bootable=False)
compose.im.images['Server-optional'] = {'i386': [image]}
try:
test_phase.check_image_sanity(compose)
except:
self.fail('Checking optional variant must not raise')
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()