Merge #325 Fix checking optional ISO images in test phase
This commit is contained in:
commit
6800501217
@ -110,11 +110,14 @@ def check_image_sanity(compose):
|
||||
manifest and logged. Otherwise the compose will be aborted.
|
||||
"""
|
||||
im = compose.im
|
||||
for variant_uid in im.images:
|
||||
variant = compose.variants[variant_uid]
|
||||
for arch in im.images[variant_uid]:
|
||||
images = im.images[variant_uid][arch]
|
||||
im.images[variant_uid][arch] = [img for img in images
|
||||
for variant in compose.get_variants():
|
||||
if variant.uid not in im.images:
|
||||
continue
|
||||
for arch in variant.arches:
|
||||
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)]
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ class DummyCompose(object):
|
||||
self.log_warning = mock.Mock()
|
||||
self.get_image_name = mock.Mock(return_value='image-name')
|
||||
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.config_dir = '/home/releng/config'
|
||||
self.notifier = None
|
||||
|
@ -7,6 +7,7 @@ try:
|
||||
except ImportError:
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -124,6 +125,25 @@ class TestCheckImageSanity(PungiTestCase):
|
||||
except:
|
||||
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__":
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user