iso-wrapper: Remove the class
It really is just a group of independent functions, so we can simplify it by removing the unused wrapper class. Instead of importing the wrapper, instantiating it and calling its methods we can import the module and call its functions directly. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
b2b5dd919b
commit
e58c78fd2f
@ -6,7 +6,7 @@ import os
|
||||
import pipes
|
||||
from collections import namedtuple
|
||||
|
||||
from .wrappers.iso import IsoWrapper
|
||||
from .wrappers import iso
|
||||
from .wrappers.jigdo import JigdoWrapper
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ fi
|
||||
""".replace('\n', '')
|
||||
|
||||
|
||||
def make_image(f, iso, opts):
|
||||
def make_image(f, opts):
|
||||
mkisofs_kwargs = {}
|
||||
|
||||
if opts.buildinstall_method:
|
||||
@ -62,12 +62,12 @@ def make_image(f, iso, opts):
|
||||
emit(f, cmd)
|
||||
|
||||
|
||||
def implant_md5(f, iso, opts):
|
||||
def implant_md5(f, opts):
|
||||
cmd = iso.get_implantisomd5_cmd(opts.iso_name, opts.supported)
|
||||
emit(f, cmd)
|
||||
|
||||
|
||||
def run_isohybrid(f, iso, opts):
|
||||
def run_isohybrid(f, opts):
|
||||
"""If the image is bootable, it should include an MBR or GPT so that it can
|
||||
be booted when written to USB disk. This is done by running isohybrid on
|
||||
the image.
|
||||
@ -77,7 +77,7 @@ def run_isohybrid(f, iso, opts):
|
||||
emit(f, cmd)
|
||||
|
||||
|
||||
def make_manifest(f, iso, opts):
|
||||
def make_manifest(f, opts):
|
||||
emit(f, iso.get_manifest_cmd(opts.iso_name))
|
||||
|
||||
|
||||
@ -103,10 +103,9 @@ def write_script(opts, f):
|
||||
emit(f, "#!/bin/bash")
|
||||
emit(f, "set -ex")
|
||||
emit(f, "cd %s" % opts.output_dir)
|
||||
iso = IsoWrapper()
|
||||
make_image(f, iso, opts)
|
||||
run_isohybrid(f, iso, opts)
|
||||
implant_md5(f, iso, opts)
|
||||
make_manifest(f, iso, opts)
|
||||
make_image(f, opts)
|
||||
run_isohybrid(f, opts)
|
||||
implant_md5(f, opts)
|
||||
make_manifest(f, opts)
|
||||
if opts.jigdo_dir:
|
||||
make_jigdo(f, opts)
|
||||
|
@ -31,7 +31,7 @@ from pungi.util import get_buildroot_rpms, get_volid, get_arch_variant_data
|
||||
from pungi.util import get_file_size, get_mtime, failable
|
||||
from pungi.wrappers.lorax import LoraxWrapper
|
||||
from pungi.wrappers.kojiwrapper import KojiWrapper
|
||||
from pungi.wrappers.iso import IsoWrapper
|
||||
from pungi.wrappers import iso
|
||||
from pungi.wrappers.scm import get_file_from_scm
|
||||
from pungi.phases.base import PhaseBase
|
||||
|
||||
@ -312,7 +312,6 @@ def link_boot_iso(compose, arch, variant, can_fail):
|
||||
except OSError:
|
||||
shutil.copy2(boot_iso_path, new_boot_iso_path)
|
||||
|
||||
iso = IsoWrapper()
|
||||
implant_md5 = iso.get_implanted_md5(new_boot_iso_path)
|
||||
iso_name = os.path.basename(new_boot_iso_path)
|
||||
iso_dir = os.path.dirname(new_boot_iso_path)
|
||||
|
@ -25,7 +25,7 @@ from productmd.images import Image
|
||||
from kobo.threads import ThreadPool, WorkerThread
|
||||
from kobo.shortcuts import run, relative_path
|
||||
|
||||
from pungi.wrappers.iso import IsoWrapper
|
||||
from pungi.wrappers import iso
|
||||
from pungi.wrappers.createrepo import CreaterepoWrapper
|
||||
from pungi.wrappers.kojiwrapper import KojiWrapper
|
||||
from pungi.phases.base import PhaseBase
|
||||
@ -246,8 +246,6 @@ class CreateIsoThread(WorkerThread):
|
||||
self.fail(compose, cmd, variant, arch)
|
||||
raise
|
||||
|
||||
iso = IsoWrapper()
|
||||
|
||||
img = Image(compose.im)
|
||||
img.path = cmd["iso_path"].replace(compose.paths.compose.topdir(), '').lstrip('/')
|
||||
img.mtime = get_mtime(cmd["iso_path"])
|
||||
@ -412,13 +410,12 @@ def prepare_iso(compose, arch, variant, disc_num=1, disc_count=None, split_iso_d
|
||||
new_di_path = os.path.join(iso_dir, ".discinfo")
|
||||
write_discinfo(new_di_path, **data)
|
||||
|
||||
i = IsoWrapper()
|
||||
if not disc_count or disc_count == 1:
|
||||
data = i.get_graft_points([tree_dir, iso_dir])
|
||||
data = iso.get_graft_points([tree_dir, iso_dir])
|
||||
else:
|
||||
data = i.get_graft_points([i._paths_from_list(tree_dir, split_iso_data["files"]), iso_dir])
|
||||
data = iso.get_graft_points([iso._paths_from_list(tree_dir, split_iso_data["files"]), iso_dir])
|
||||
|
||||
# TODO: /content /graft-points
|
||||
gp = "%s-graft-points" % iso_dir
|
||||
i.write_graft_points(gp, data, exclude=["*/lost+found", "*/boot.iso"])
|
||||
iso.write_graft_points(gp, data, exclude=["*/lost+found", "*/boot.iso"])
|
||||
return gp
|
||||
|
@ -25,7 +25,7 @@ from kobo.shortcuts import run, save_to_file, force_list
|
||||
from productmd.images import Image
|
||||
|
||||
from pungi.wrappers.kojiwrapper import KojiWrapper
|
||||
from pungi.wrappers.iso import IsoWrapper
|
||||
from pungi.wrappers import iso
|
||||
from pungi.phases import base
|
||||
from pungi.util import get_arch_variant_data, makedirs, get_mtime, get_file_size, failable
|
||||
from pungi.paths import translate_path
|
||||
@ -268,7 +268,6 @@ class CreateLiveImageThread(WorkerThread):
|
||||
:param iso_path: (str) absolute path to the ISO
|
||||
"""
|
||||
dir, filename = os.path.split(iso_path)
|
||||
iso = IsoWrapper()
|
||||
run("cd %s && %s" % (pipes.quote(dir), iso.get_manifest_cmd(filename)))
|
||||
|
||||
def _sign_image(self, koji_wrapper, compose, cmd, koji_task_id):
|
||||
|
@ -100,8 +100,7 @@ class OstreeInstallerThread(WorkerThread):
|
||||
def _add_to_manifest(self, compose, variant, arch, filename):
|
||||
full_iso_path = compose.paths.compose.iso_path(arch, variant, filename)
|
||||
iso_path = compose.paths.compose.iso_path(arch, variant, filename, relative=True)
|
||||
iso_wrapper = iso.IsoWrapper()
|
||||
implant_md5 = iso_wrapper.get_implanted_md5(full_iso_path)
|
||||
implant_md5 = iso.get_implanted_md5(full_iso_path)
|
||||
|
||||
img = images.Image(compose.im)
|
||||
img.path = iso_path
|
||||
@ -118,7 +117,7 @@ class OstreeInstallerThread(WorkerThread):
|
||||
setattr(img, 'can_fail', self.can_fail)
|
||||
setattr(img, 'deliverable', 'ostree-installer')
|
||||
try:
|
||||
img.volume_id = iso_wrapper.get_volume_id(full_iso_path)
|
||||
img.volume_id = iso.get_volume_id(full_iso_path)
|
||||
except RuntimeError:
|
||||
pass
|
||||
compose.im.add(variant.uid, arch, img)
|
||||
|
@ -47,7 +47,7 @@ from kobo.shortcuts import run
|
||||
from pungi.arch import split_name_arch
|
||||
from pungi.util import makedirs, pkg_is_rpm
|
||||
from pungi.phases.base import PhaseBase
|
||||
from pungi.wrappers.iso import IsoWrapper
|
||||
from pungi.wrappers import iso
|
||||
from pungi.wrappers.scm import get_file_from_scm, get_dir_from_scm
|
||||
|
||||
|
||||
@ -178,8 +178,6 @@ def rebuild_boot_iso(compose, arch, variant, package_sets):
|
||||
|
||||
compose.log_info("[BEGIN] %s" % msg)
|
||||
|
||||
iso = IsoWrapper()
|
||||
|
||||
# read the original volume id
|
||||
volume_id = iso.get_volume_id(boot_iso)
|
||||
|
||||
|
@ -380,10 +380,6 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False)
|
||||
if len(volid) <= 32:
|
||||
break
|
||||
|
||||
# from wrappers.iso import IsoWrapper
|
||||
# iso = IsoWrapper(logger=compose._logger)
|
||||
# volid = iso._truncate_volid(volid)
|
||||
|
||||
if volid and len(volid) > 32:
|
||||
raise ValueError("Could not create volume ID <= 32 characters")
|
||||
|
||||
|
@ -29,9 +29,7 @@ if sys.version_info[0] == 3:
|
||||
return (a > b) - (a < b)
|
||||
|
||||
|
||||
class IsoWrapper(kobo.log.LoggingBase):
|
||||
|
||||
def get_boot_options(self, arch, createfrom, efi=True):
|
||||
def get_boot_options(arch, createfrom, efi=True):
|
||||
"""Checks to see what we need as the -b option for mkisofs"""
|
||||
|
||||
if arch in ("arm", "armhfp"):
|
||||
@ -105,28 +103,24 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
|
||||
raise ValueError("Unknown arch: %s" % arch)
|
||||
|
||||
def _truncate_volid(self, volid):
|
||||
|
||||
def _truncate_volid(volid):
|
||||
if len(volid) > 32:
|
||||
old_volid = volid
|
||||
volid = volid.replace("-", "")
|
||||
self.log_warning("Truncating volume ID from '%s' to '%s'" % (old_volid, volid))
|
||||
|
||||
if len(volid) > 32:
|
||||
old_volid = volid
|
||||
volid = volid.replace(" ", "")
|
||||
self.log_warning("Truncating volume ID from '%s' to '%s'" % (old_volid, volid))
|
||||
|
||||
if len(volid) > 32:
|
||||
old_volid = volid
|
||||
volid = volid.replace("Supplementary", "Supp")
|
||||
self.log_warning("Truncating volume ID from '%s' to '%s'" % (old_volid, volid))
|
||||
|
||||
if len(volid) > 32:
|
||||
raise ValueError("Volume ID must be less than 32 character: %s" % volid)
|
||||
|
||||
return volid
|
||||
|
||||
def get_mkisofs_cmd(self, iso, paths, appid=None, volid=None, volset=None, exclude=None, verbose=False, boot_args=None, input_charset="utf-8", graft_points=None):
|
||||
|
||||
def get_mkisofs_cmd(iso, paths, appid=None, volid=None, volset=None, exclude=None, verbose=False, boot_args=None, input_charset="utf-8", graft_points=None):
|
||||
# following options are always enabled
|
||||
untranslated_filenames = True
|
||||
translation_table = True
|
||||
@ -142,7 +136,7 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
cmd.append("-untranslated-filenames")
|
||||
|
||||
if volid:
|
||||
cmd.extend(["-volid", self._truncate_volid(volid)])
|
||||
cmd.extend(["-volid", _truncate_volid(volid)])
|
||||
|
||||
if joliet:
|
||||
cmd.append("-J")
|
||||
@ -183,28 +177,31 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
|
||||
return cmd
|
||||
|
||||
def get_implantisomd5_cmd(self, iso_path, supported=False):
|
||||
|
||||
def get_implantisomd5_cmd(iso_path, supported=False):
|
||||
cmd = ["/usr/bin/implantisomd5"]
|
||||
if supported:
|
||||
cmd.append("--supported-iso")
|
||||
cmd.append(iso_path)
|
||||
return cmd
|
||||
|
||||
def get_checkisomd5_cmd(self, iso_path, just_print=False):
|
||||
|
||||
def get_checkisomd5_cmd(iso_path, just_print=False):
|
||||
cmd = ["/usr/bin/checkisomd5"]
|
||||
if just_print:
|
||||
cmd.append("--md5sumonly")
|
||||
cmd.append(iso_path)
|
||||
return cmd
|
||||
|
||||
def get_implanted_md5(self, iso_path):
|
||||
cmd = self.get_checkisomd5_cmd(iso_path, just_print=True)
|
||||
|
||||
def get_implanted_md5(iso_path):
|
||||
cmd = get_checkisomd5_cmd(iso_path, just_print=True)
|
||||
retcode, output = run(cmd)
|
||||
line = output.splitlines()[0]
|
||||
result = line.rsplit(":")[-1].strip()
|
||||
return result
|
||||
return line.rsplit(":")[-1].strip()
|
||||
|
||||
def get_isohybrid_cmd(self, iso_path, arch):
|
||||
|
||||
def get_isohybrid_cmd(iso_path, arch):
|
||||
# isohybrid is in syslinux which is x86 only
|
||||
cmd = ["/usr/bin/isohybrid"]
|
||||
# uefi is only supported on x86_64
|
||||
@ -213,10 +210,12 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
cmd.append(iso_path)
|
||||
return cmd
|
||||
|
||||
def get_manifest_cmd(self, iso_name):
|
||||
|
||||
def get_manifest_cmd(iso_name):
|
||||
return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s.manifest" % (pipes.quote(iso_name), pipes.quote(iso_name))
|
||||
|
||||
def get_volume_id(self, path):
|
||||
|
||||
def get_volume_id(path):
|
||||
cmd = ["isoinfo", "-d", "-i", path]
|
||||
retcode, output = run(cmd)
|
||||
|
||||
@ -227,7 +226,8 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
|
||||
raise RuntimeError("Could not read Volume ID")
|
||||
|
||||
def get_graft_points(self, paths, exclusive_paths=None, exclude=None):
|
||||
|
||||
def get_graft_points(paths, exclusive_paths=None, exclude=None):
|
||||
# path priority in ascending order (1st = lowest prio)
|
||||
# paths merge according to priority
|
||||
# exclusive paths override whole dirs
|
||||
@ -240,17 +240,17 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
if isinstance(i, dict):
|
||||
tree = i
|
||||
else:
|
||||
tree = self._scan_tree(i)
|
||||
result = self._merge_trees(result, tree)
|
||||
tree = _scan_tree(i)
|
||||
result = _merge_trees(result, tree)
|
||||
|
||||
for i in exclusive_paths:
|
||||
tree = self._scan_tree(i)
|
||||
result = self._merge_trees(result, tree, exclusive=True)
|
||||
tree = _scan_tree(i)
|
||||
result = _merge_trees(result, tree, exclusive=True)
|
||||
|
||||
# TODO: exclude
|
||||
return result
|
||||
|
||||
def _paths_from_list(self, root, paths):
|
||||
def _paths_from_list(root, paths):
|
||||
root = os.path.abspath(root).rstrip("/") + "/"
|
||||
result = {}
|
||||
for i in paths:
|
||||
@ -259,7 +259,8 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
result[key] = i
|
||||
return result
|
||||
|
||||
def _scan_tree(self, path):
|
||||
|
||||
def _scan_tree(path):
|
||||
path = os.path.abspath(path)
|
||||
result = {}
|
||||
for root, dirs, files in os.walk(path):
|
||||
@ -276,7 +277,8 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
|
||||
return result
|
||||
|
||||
def _merge_trees(self, tree1, tree2, exclusive=False):
|
||||
|
||||
def _merge_trees(tree1, tree2, exclusive=False):
|
||||
# tree2 has higher priority
|
||||
result = tree2.copy()
|
||||
all_dirs = set([os.path.dirname(i).rstrip("/") for i in result if os.path.dirname(i) != ""])
|
||||
@ -298,7 +300,8 @@ class IsoWrapper(kobo.log.LoggingBase):
|
||||
result[i] = tree1[i]
|
||||
return result
|
||||
|
||||
def write_graft_points(self, file_name, h, exclude=None):
|
||||
|
||||
def write_graft_points(file_name, h, exclude=None):
|
||||
exclude = exclude or []
|
||||
result = {}
|
||||
seen_dirs = set()
|
||||
|
@ -636,11 +636,10 @@ class TestSymlinkIso(PungiTestCase):
|
||||
@mock.patch('pungi.phases.buildinstall.Image')
|
||||
@mock.patch('pungi.phases.buildinstall.get_mtime')
|
||||
@mock.patch('pungi.phases.buildinstall.get_file_size')
|
||||
@mock.patch('pungi.phases.buildinstall.IsoWrapper')
|
||||
@mock.patch('pungi.phases.buildinstall.iso')
|
||||
@mock.patch('pungi.phases.buildinstall.run')
|
||||
def test_hardlink(self, run, IsoWrapperCls, get_file_size, get_mtime, ImageCls):
|
||||
def test_hardlink(self, run, iso, get_file_size, get_mtime, ImageCls):
|
||||
self.compose.conf = {'buildinstall_symlink': False, 'disc_types': {}}
|
||||
IsoWrapper = IsoWrapperCls.return_value
|
||||
get_file_size.return_value = 1024
|
||||
get_mtime.return_value = 13579
|
||||
|
||||
@ -655,14 +654,14 @@ class TestSymlinkIso(PungiTestCase):
|
||||
self.compose.get_image_name.mock_calls,
|
||||
[mock.call('x86_64', self.compose.variants['Server'],
|
||||
disc_type='boot', disc_num=None, suffix='.iso')])
|
||||
self.assertItemsEqual(IsoWrapper.get_implanted_md5.mock_calls,
|
||||
self.assertItemsEqual(iso.get_implanted_md5.mock_calls,
|
||||
[mock.call(tgt)])
|
||||
self.assertItemsEqual(IsoWrapper.get_manifest_cmd.mock_calls,
|
||||
self.assertItemsEqual(iso.get_manifest_cmd.mock_calls,
|
||||
[mock.call('image-name')])
|
||||
self.assertItemsEqual(IsoWrapper.get_volume_id.mock_calls,
|
||||
self.assertItemsEqual(iso.get_volume_id.mock_calls,
|
||||
[mock.call(tgt)])
|
||||
self.assertItemsEqual(run.mock_calls,
|
||||
[mock.call(IsoWrapper.get_manifest_cmd.return_value,
|
||||
[mock.call(iso.get_manifest_cmd.return_value,
|
||||
workdir=self.topdir + '/compose/Server/x86_64/iso')])
|
||||
|
||||
image = ImageCls.return_value
|
||||
@ -675,7 +674,7 @@ class TestSymlinkIso(PungiTestCase):
|
||||
self.assertEqual(image.disc_number, 1)
|
||||
self.assertEqual(image.disc_count, 1)
|
||||
self.assertEqual(image.bootable, True)
|
||||
self.assertEqual(image.implant_md5, IsoWrapper.get_implanted_md5.return_value)
|
||||
self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value)
|
||||
self.assertEqual(image.can_fail, False)
|
||||
self.assertEqual(self.compose.im.add.mock_calls,
|
||||
[mock.call('Server', 'x86_64', image)])
|
||||
@ -683,14 +682,13 @@ class TestSymlinkIso(PungiTestCase):
|
||||
@mock.patch('pungi.phases.buildinstall.Image')
|
||||
@mock.patch('pungi.phases.buildinstall.get_mtime')
|
||||
@mock.patch('pungi.phases.buildinstall.get_file_size')
|
||||
@mock.patch('pungi.phases.buildinstall.IsoWrapper')
|
||||
@mock.patch('pungi.phases.buildinstall.iso')
|
||||
@mock.patch('pungi.phases.buildinstall.run')
|
||||
def test_hardlink_with_custom_type(self, run, IsoWrapperCls, get_file_size, get_mtime, ImageCls):
|
||||
def test_hardlink_with_custom_type(self, run, iso, get_file_size, get_mtime, ImageCls):
|
||||
self.compose.conf = {
|
||||
'buildinstall_symlink': False,
|
||||
'disc_types': {'boot': 'netinst'},
|
||||
}
|
||||
IsoWrapper = IsoWrapperCls.return_value
|
||||
get_file_size.return_value = 1024
|
||||
get_mtime.return_value = 13579
|
||||
|
||||
@ -705,14 +703,14 @@ class TestSymlinkIso(PungiTestCase):
|
||||
self.compose.get_image_name.mock_calls,
|
||||
[mock.call('x86_64', self.compose.variants['Server'],
|
||||
disc_type='netinst', disc_num=None, suffix='.iso')])
|
||||
self.assertItemsEqual(IsoWrapper.get_implanted_md5.mock_calls,
|
||||
self.assertItemsEqual(iso.get_implanted_md5.mock_calls,
|
||||
[mock.call(tgt)])
|
||||
self.assertItemsEqual(IsoWrapper.get_manifest_cmd.mock_calls,
|
||||
self.assertItemsEqual(iso.get_manifest_cmd.mock_calls,
|
||||
[mock.call('image-name')])
|
||||
self.assertItemsEqual(IsoWrapper.get_volume_id.mock_calls,
|
||||
self.assertItemsEqual(iso.get_volume_id.mock_calls,
|
||||
[mock.call(tgt)])
|
||||
self.assertItemsEqual(run.mock_calls,
|
||||
[mock.call(IsoWrapper.get_manifest_cmd.return_value,
|
||||
[mock.call(iso.get_manifest_cmd.return_value,
|
||||
workdir=self.topdir + '/compose/Server/x86_64/iso')])
|
||||
|
||||
image = ImageCls.return_value
|
||||
@ -725,7 +723,7 @@ class TestSymlinkIso(PungiTestCase):
|
||||
self.assertEqual(image.disc_number, 1)
|
||||
self.assertEqual(image.disc_count, 1)
|
||||
self.assertEqual(image.bootable, True)
|
||||
self.assertEqual(image.implant_md5, IsoWrapper.get_implanted_md5.return_value)
|
||||
self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value)
|
||||
self.assertEqual(image.can_fail, True)
|
||||
self.assertEqual(self.compose.im.add.mock_calls,
|
||||
[mock.call('Server', 'x86_64', image)])
|
||||
|
@ -208,11 +208,11 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
|
||||
|
||||
class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_in_runroot(self, KojiWrapper, get_file_size, get_mtime, IsoWrapper):
|
||||
def test_process_in_runroot(self, KojiWrapper, get_file_size, get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -256,9 +256,9 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
run_runroot.call_args_list,
|
||||
[mock.call(get_runroot_cmd.return_value,
|
||||
log_file='%s/logs/x86_64/createiso-image-name.x86_64.log' % self.topdir)])
|
||||
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
|
||||
self.assertEqual(iso.get_implanted_md5.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
|
||||
self.assertEqual(iso.get_volume_id.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
|
||||
self.assertEqual(len(compose.im.add.call_args_list), 1)
|
||||
@ -272,11 +272,11 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
self.assertEqual(image.type, 'dvd')
|
||||
self.assertEqual(image.subvariant, 'Server')
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_source_iso(self, KojiWrapper, get_file_size, get_mtime, IsoWrapper):
|
||||
def test_process_source_iso(self, KojiWrapper, get_file_size, get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -320,9 +320,9 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
run_runroot.call_args_list,
|
||||
[mock.call(get_runroot_cmd.return_value,
|
||||
log_file='%s/logs/src/createiso-image-name.src.log' % self.topdir)])
|
||||
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
|
||||
self.assertEqual(iso.get_implanted_md5.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
|
||||
self.assertEqual(iso.get_volume_id.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
|
||||
self.assertEqual(len(compose.im.add.call_args_list), 2)
|
||||
@ -336,11 +336,11 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
self.assertEqual(image.type, 'dvd')
|
||||
self.assertEqual(image.subvariant, 'Server')
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_bootable(self, KojiWrapper, get_file_size, get_mtime, IsoWrapper):
|
||||
def test_process_bootable(self, KojiWrapper, get_file_size, get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -386,9 +386,9 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
run_runroot.call_args_list,
|
||||
[mock.call(get_runroot_cmd.return_value,
|
||||
log_file='%s/logs/x86_64/createiso-image-name.x86_64.log' % self.topdir)])
|
||||
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
|
||||
self.assertEqual(iso.get_implanted_md5.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
|
||||
self.assertEqual(iso.get_volume_id.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
|
||||
self.assertEqual(len(compose.im.add.call_args_list), 1)
|
||||
@ -402,12 +402,12 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
self.assertEqual(image.type, 'dvd')
|
||||
self.assertEqual(image.subvariant, 'Server')
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_in_runroot_non_existing_tag(self, KojiWrapper, get_file_size,
|
||||
get_mtime, IsoWrapper):
|
||||
get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -434,11 +434,11 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
|
||||
self.assertEqual('Tag "f25-build" does not exist.', str(ctx.exception))
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_in_runroot_crash(self, KojiWrapper, get_file_size, get_mtime, IsoWrapper):
|
||||
def test_process_in_runroot_crash(self, KojiWrapper, get_file_size, get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -472,11 +472,11 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
mock.call('BOOM')
|
||||
])
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_in_runroot_fail(self, KojiWrapper, get_file_size, get_mtime, IsoWrapper):
|
||||
def test_process_in_runroot_fail(self, KojiWrapper, get_file_size, get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -515,12 +515,12 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
% (self.topdir + '/logs/x86_64/createiso-image-name.x86_64.log'))
|
||||
])
|
||||
|
||||
@mock.patch('pungi.phases.createiso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.createiso.iso')
|
||||
@mock.patch('pungi.phases.createiso.get_mtime')
|
||||
@mock.patch('pungi.phases.createiso.get_file_size')
|
||||
@mock.patch('pungi.phases.createiso.run')
|
||||
@mock.patch('pungi.phases.createiso.KojiWrapper')
|
||||
def test_process_locally(self, KojiWrapper, run, get_file_size, get_mtime, IsoWrapper):
|
||||
def test_process_locally(self, KojiWrapper, run, get_file_size, get_mtime, iso):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_short': 'test',
|
||||
'release_version': '1.0',
|
||||
@ -547,9 +547,9 @@ class CreateisoThreadTest(helpers.PungiTestCase):
|
||||
run.call_args_list,
|
||||
[mock.call(cmd['cmd'], show_cmd=True,
|
||||
logfile='%s/logs/x86_64/createiso-image-name.x86_64.log' % self.topdir)])
|
||||
self.assertEqual(IsoWrapper.return_value.get_implanted_md5.call_args_list,
|
||||
self.assertEqual(iso.get_implanted_md5.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
self.assertEqual(IsoWrapper.return_value.get_volume_id.call_args_list,
|
||||
self.assertEqual(iso.get_volume_id.call_args_list,
|
||||
[mock.call(cmd['iso_path'])])
|
||||
|
||||
self.assertEqual(len(compose.im.add.call_args_list), 1)
|
||||
|
@ -55,7 +55,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
'image_volid_formats': ['{release_short}-{variant}-{arch}'],
|
||||
})
|
||||
|
||||
def assertImageAdded(self, compose, ImageCls, IsoWrapper):
|
||||
def assertImageAdded(self, compose, ImageCls, iso):
|
||||
image = ImageCls.return_value
|
||||
self.assertEqual(image.path, 'Everything/x86_64/iso/image-name')
|
||||
self.assertEqual(image.mtime, 13579)
|
||||
@ -66,7 +66,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
self.assertEqual(image.disc_number, 1)
|
||||
self.assertEqual(image.disc_count, 1)
|
||||
self.assertEqual(image.bootable, True)
|
||||
self.assertEqual(image.implant_md5, IsoWrapper.return_value.get_implanted_md5.return_value)
|
||||
self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value)
|
||||
self.assertEqual(compose.im.add.mock_calls,
|
||||
[mock.call('Everything', 'x86_64', image)])
|
||||
|
||||
@ -111,10 +111,10 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.ostree_installer.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_run(self, KojiWrapper, link, IsoWrapper,
|
||||
def test_run(self, KojiWrapper, link, iso,
|
||||
get_file_size, get_mtime, ImageCls, run):
|
||||
self.compose.supported = False
|
||||
pool = mock.Mock()
|
||||
@ -140,17 +140,17 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
'file://%s/compose/Everything/x86_64/os' % self.topdir,
|
||||
cfg['release'])
|
||||
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
||||
self.assertImageAdded(self.compose, ImageCls, IsoWrapper)
|
||||
self.assertImageAdded(self.compose, ImageCls, iso)
|
||||
self.assertAllCopied(run)
|
||||
|
||||
@mock.patch('kobo.shortcuts.run')
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.ostree_installer.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_run_external_source(self, KojiWrapper, link, IsoWrapper,
|
||||
def test_run_external_source(self, KojiWrapper, link, iso,
|
||||
get_file_size, get_mtime, ImageCls, run):
|
||||
pool = mock.Mock()
|
||||
cfg = {
|
||||
@ -173,18 +173,18 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
|
||||
self.assertRunrootCall(koji, 'http://example.com/repo/x86_64/', cfg['release'], isfinal=True)
|
||||
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
||||
self.assertImageAdded(self.compose, ImageCls, IsoWrapper)
|
||||
self.assertImageAdded(self.compose, ImageCls, iso)
|
||||
self.assertAllCopied(run)
|
||||
|
||||
@mock.patch('kobo.shortcuts.run')
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.wrappers.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_fail_with_relative_template_path_but_no_repo(self, KojiWrapper, link,
|
||||
IsoWrapper, get_file_size,
|
||||
iso, get_file_size,
|
||||
get_mtime, ImageCls, run):
|
||||
pool = mock.Mock()
|
||||
cfg = {
|
||||
@ -213,10 +213,10 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.ostree_installer.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_run_clone_templates(self, KojiWrapper, link, IsoWrapper,
|
||||
def test_run_clone_templates(self, KojiWrapper, link, iso,
|
||||
get_file_size, get_mtime, ImageCls, run,
|
||||
get_dir_from_scm):
|
||||
pool = mock.Mock()
|
||||
@ -254,17 +254,17 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
extra=['--add-template=%s/some_file.txt' % templ_dir,
|
||||
'--add-arch-template=%s/other_file.txt' % templ_dir])
|
||||
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
||||
self.assertImageAdded(self.compose, ImageCls, IsoWrapper)
|
||||
self.assertImageAdded(self.compose, ImageCls, iso)
|
||||
self.assertAllCopied(run)
|
||||
|
||||
@mock.patch('kobo.shortcuts.run')
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.ostree_installer.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_run_with_implicit_release(self, KojiWrapper, link, IsoWrapper,
|
||||
def test_run_with_implicit_release(self, KojiWrapper, link, iso,
|
||||
get_file_size, get_mtime, ImageCls, run):
|
||||
pool = mock.Mock()
|
||||
cfg = {
|
||||
@ -312,17 +312,17 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
'--add-arch-template-var=ostree_ref=fedora-atomic/Rawhide/x86_64/docker-host']
|
||||
)
|
||||
self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
|
||||
self.assertImageAdded(self.compose, ImageCls, IsoWrapper)
|
||||
self.assertImageAdded(self.compose, ImageCls, iso)
|
||||
self.assertAllCopied(run)
|
||||
|
||||
@mock.patch('kobo.shortcuts.run')
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.ostree_installer.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_fail_crash(self, KojiWrapper, link, IsoWrapper, get_file_size,
|
||||
def test_fail_crash(self, KojiWrapper, link, iso, get_file_size,
|
||||
get_mtime, ImageCls, run):
|
||||
pool = mock.Mock()
|
||||
cfg = {
|
||||
@ -345,10 +345,10 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('pungi.phases.ostree_installer.iso')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_fail_runroot_fail(self, KojiWrapper, link, IsoWrapper,
|
||||
def test_fail_runroot_fail(self, KojiWrapper, link, iso,
|
||||
get_file_size, get_mtime, ImageCls, run):
|
||||
pool = mock.Mock()
|
||||
cfg = {
|
||||
|
Loading…
Reference in New Issue
Block a user