2018-05-09 13:39:36 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
import unittest2 as unittest
|
|
|
|
except ImportError:
|
|
|
|
import unittest
|
|
|
|
import mock
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
|
|
|
|
from tests import helpers
|
|
|
|
from pungi.phases import extra_isos
|
|
|
|
|
|
|
|
|
|
|
|
@mock.patch('pungi.phases.extra_isos.ThreadPool')
|
|
|
|
class ExtraIsosPhaseTest(helpers.PungiTestCase):
|
|
|
|
|
|
|
|
def test_logs_extra_arches(self, ThreadPool):
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
'arches': ['x86_64', 'ppc64le', 'aarch64'],
|
|
|
|
}
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'extra_isos': {
|
|
|
|
'^Server$': [cfg]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.validate()
|
|
|
|
|
|
|
|
self.assertEqual(len(compose.log_warning.call_args_list), 1)
|
|
|
|
|
|
|
|
def test_one_task_for_each_arch(self, ThreadPool):
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
}
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'extra_isos': {
|
|
|
|
'^Server$': [cfg]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 3)
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ThreadPool.return_value.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, cfg, compose.variants['Server'], 'x86_64')),
|
|
|
|
mock.call((compose, cfg, compose.variants['Server'], 'amd64')),
|
|
|
|
mock.call((compose, cfg, compose.variants['Server'], 'src'))]
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_filter_arches(self, ThreadPool):
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
'arches': ['x86_64'],
|
|
|
|
}
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'extra_isos': {
|
|
|
|
'^Server$': [cfg]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 2)
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ThreadPool.return_value.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, cfg, compose.variants['Server'], 'x86_64')),
|
|
|
|
mock.call((compose, cfg, compose.variants['Server'], 'src'))]
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_skip_source(self, ThreadPool):
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
'skip_src': True,
|
|
|
|
}
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'extra_isos': {
|
|
|
|
'^Server$': [cfg]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
phase = extra_isos.ExtraIsosPhase(compose)
|
|
|
|
phase.run()
|
|
|
|
|
|
|
|
self.assertEqual(len(ThreadPool.return_value.add.call_args_list), 2)
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ThreadPool.return_value.queue_put.call_args_list,
|
|
|
|
[mock.call((compose, cfg, compose.variants['Server'], 'x86_64')),
|
|
|
|
mock.call((compose, cfg, compose.variants['Server'], 'amd64'))]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
@mock.patch('pungi.phases.extra_isos.prepare_media_metadata')
|
2018-05-09 13:39:36 +00:00
|
|
|
@mock.patch('pungi.phases.extra_isos.get_volume_id')
|
|
|
|
@mock.patch('pungi.phases.extra_isos.get_filename')
|
|
|
|
@mock.patch('pungi.phases.extra_isos.get_iso_contents')
|
|
|
|
@mock.patch('pungi.phases.extra_isos.get_extra_files')
|
|
|
|
@mock.patch('pungi.phases.extra_isos.run_createiso_command')
|
|
|
|
@mock.patch('pungi.phases.extra_isos.add_iso_to_metadata')
|
|
|
|
class ExtraIsosThreadTest(helpers.PungiTestCase):
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_binary_bootable_image(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'bootable': True,
|
|
|
|
'buildinstall_method': 'lorax'
|
|
|
|
})
|
|
|
|
server = compose.variants['Server']
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = 'my.iso'
|
|
|
|
gvi.return_value = 'my volume id'
|
|
|
|
gic.return_value = '/tmp/iso-graft-points'
|
|
|
|
|
2018-10-10 14:06:46 +00:00
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, cfg, server, 'x86_64'), 1)
|
|
|
|
|
|
|
|
self.assertEqual(gfn.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', None)])
|
|
|
|
self.assertEqual(gvi.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', [])])
|
|
|
|
self.assertEqual(gef.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
'x86_64',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-10-10 14:06:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
|
|
|
[mock.call(False, 1, compose, True, 'x86_64',
|
|
|
|
['bash', os.path.join(self.topdir, 'work/x86_64/tmp-Server/extraiso-my.iso.sh')],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(self.topdir, 'logs/x86_64/extraiso-my.iso.x86_64.log'),
|
|
|
|
with_jigdo=True)]
|
|
|
|
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64',
|
|
|
|
os.path.join(self.topdir, 'compose/Server/x86_64/iso/my.iso'),
|
|
|
|
True, additional_variants=["Client"])]
|
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
2018-10-10 14:06:46 +00:00
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_binary_bootable_image_without_jigdo(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-10-10 14:06:46 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'bootable': True,
|
|
|
|
'buildinstall_method': 'lorax',
|
|
|
|
'create_jigdo': False,
|
|
|
|
})
|
|
|
|
server = compose.variants['Server']
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = 'my.iso'
|
|
|
|
gvi.return_value = 'my volume id'
|
|
|
|
gic.return_value = '/tmp/iso-graft-points'
|
|
|
|
|
2018-05-09 13:39:36 +00:00
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, cfg, server, 'x86_64'), 1)
|
|
|
|
|
|
|
|
self.assertEqual(gfn.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', None)])
|
|
|
|
self.assertEqual(gvi.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', [])])
|
|
|
|
self.assertEqual(gef.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
'x86_64',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
|
|
|
[mock.call(False, 1, compose, True, 'x86_64',
|
|
|
|
['bash', os.path.join(self.topdir, 'work/x86_64/tmp-Server/extraiso-my.iso.sh')],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(self.topdir, 'logs/x86_64/extraiso-my.iso.x86_64.log'),
|
|
|
|
with_jigdo=False)]
|
|
|
|
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64',
|
|
|
|
os.path.join(self.topdir, 'compose/Server/x86_64/iso/my.iso'),
|
2018-09-27 12:50:47 +00:00
|
|
|
True, additional_variants=["Client"])]
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2019-02-12 11:09:08 +00:00
|
|
|
def test_image_with_max_size(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
"bootable": True,
|
|
|
|
"buildinstall_method": "lorax"
|
|
|
|
})
|
|
|
|
server = compose.variants["Server"]
|
|
|
|
cfg = {
|
|
|
|
"include_variants": ["Client"],
|
|
|
|
"max_size": 15,
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = "my.iso"
|
|
|
|
gvi.return_value = "my volume id"
|
|
|
|
gic.return_value = "/tmp/iso-graft-points"
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch("time.sleep"):
|
|
|
|
t.process((compose, cfg, server, "x86_64"), 1)
|
|
|
|
|
|
|
|
self.assertEqual(gfn.call_args_list,
|
|
|
|
[mock.call(compose, server, "x86_64", None)])
|
|
|
|
self.assertEqual(gvi.call_args_list,
|
|
|
|
[mock.call(compose, server, "x86_64", [])])
|
|
|
|
self.assertEqual(gef.call_args_list,
|
|
|
|
[mock.call(compose, server, "x86_64", [])])
|
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
|
|
|
[mock.call(False, 1, compose, True, "x86_64",
|
|
|
|
["bash", os.path.join(self.topdir, "work/x86_64/tmp-Server/extraiso-my.iso.sh")],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(self.topdir, "logs/x86_64/extraiso-my.iso.x86_64.log"),
|
|
|
|
with_jigdo=True)]
|
|
|
|
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
|
|
|
[mock.call(compose, server, "x86_64",
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/iso/my.iso"),
|
|
|
|
True, additional_variants=["Client"])]
|
|
|
|
)
|
|
|
|
self.assertEqual(aitm.return_value._max_size, 15)
|
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_binary_image_custom_naming(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
server = compose.variants['Server']
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
'filename': 'fn',
|
|
|
|
'volid': ['v1', 'v2'],
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = 'my.iso'
|
|
|
|
gvi.return_value = 'my volume id'
|
|
|
|
gic.return_value = '/tmp/iso-graft-points'
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, cfg, server, 'x86_64'), 1)
|
|
|
|
|
|
|
|
self.assertEqual(gfn.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', 'fn')])
|
|
|
|
self.assertEqual(gvi.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', ['v1', 'v2'])])
|
|
|
|
self.assertEqual(gef.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64', [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
'x86_64',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
|
|
|
bootable=False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
|
|
|
[mock.call(False, 1, compose, False, 'x86_64',
|
|
|
|
['bash', os.path.join(self.topdir, 'work/x86_64/tmp-Server/extraiso-my.iso.sh')],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(self.topdir, 'logs/x86_64/extraiso-my.iso.x86_64.log'),
|
2018-10-10 14:06:46 +00:00
|
|
|
with_jigdo=True)]
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
|
|
|
[mock.call(compose, server, 'x86_64',
|
|
|
|
os.path.join(self.topdir, 'compose/Server/x86_64/iso/my.iso'),
|
2018-09-27 12:50:47 +00:00
|
|
|
False, additional_variants=["Client"])]
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "x86_64")])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_source_is_not_bootable(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {
|
|
|
|
'bootable': True,
|
|
|
|
'buildinstall_method': 'lorax'
|
|
|
|
})
|
|
|
|
server = compose.variants['Server']
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = 'my.iso'
|
|
|
|
gvi.return_value = 'my volume id'
|
|
|
|
gic.return_value = '/tmp/iso-graft-points'
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, cfg, server, 'src'), 1)
|
|
|
|
|
|
|
|
self.assertEqual(gfn.call_args_list,
|
|
|
|
[mock.call(compose, server, 'src', None)])
|
|
|
|
self.assertEqual(gvi.call_args_list,
|
|
|
|
[mock.call(compose, server, 'src', [])])
|
|
|
|
self.assertEqual(gef.call_args_list,
|
|
|
|
[mock.call(compose, server, 'src', [])])
|
2018-11-09 09:29:28 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gic.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
compose,
|
|
|
|
server,
|
|
|
|
'src',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
|
|
|
bootable=False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rcc.call_args_list,
|
|
|
|
[mock.call(False, 1, compose, False, 'src',
|
|
|
|
['bash', os.path.join(self.topdir, 'work/src/tmp-Server/extraiso-my.iso.sh')],
|
|
|
|
[self.topdir],
|
|
|
|
log_file=os.path.join(self.topdir, 'logs/src/extraiso-my.iso.src.log'),
|
2018-10-10 14:06:46 +00:00
|
|
|
with_jigdo=True)]
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
aitm.call_args_list,
|
|
|
|
[mock.call(compose, server, 'src',
|
|
|
|
os.path.join(self.topdir, 'compose/Server/source/iso/my.iso'),
|
2018-09-27 12:50:47 +00:00
|
|
|
False, additional_variants=["Client"])]
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
2018-10-17 12:06:43 +00:00
|
|
|
self.assertEqual(pmm.call_args_list, [mock.call(compose, server, "src")])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_failable_failed(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
server = compose.variants['Server']
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
'failable_arches': ['x86_64'],
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = 'my.iso'
|
|
|
|
gvi.return_value = 'my volume id'
|
|
|
|
gic.return_value = '/tmp/iso-graft-points'
|
|
|
|
rcc.side_effect = helpers.mk_boom()
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, cfg, server, 'x86_64'), 1)
|
|
|
|
|
|
|
|
self.assertEqual(aitm.call_args_list, [])
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
def test_non_failable_failed(self, aitm, rcc, gef, gic, gfn, gvi, pmm):
|
2018-05-09 13:39:36 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
server = compose.variants['Server']
|
|
|
|
cfg = {
|
|
|
|
'include_variants': ['Client'],
|
|
|
|
}
|
|
|
|
|
|
|
|
gfn.return_value = 'my.iso'
|
|
|
|
gvi.return_value = 'my volume id'
|
|
|
|
gic.return_value = '/tmp/iso-graft-points'
|
|
|
|
rcc.side_effect = helpers.mk_boom(RuntimeError)
|
|
|
|
|
|
|
|
t = extra_isos.ExtraIsosThread(mock.Mock())
|
|
|
|
with self.assertRaises(RuntimeError):
|
|
|
|
with mock.patch('time.sleep'):
|
|
|
|
t.process((compose, cfg, server, 'x86_64'), 1)
|
|
|
|
|
|
|
|
self.assertEqual(aitm.call_args_list, [])
|
|
|
|
|
|
|
|
|
2018-11-14 14:41:36 +00:00
|
|
|
@mock.patch("pungi.metadata.write_extra_files")
|
2018-05-09 13:39:36 +00:00
|
|
|
@mock.patch('pungi.phases.extra_isos.get_file_from_scm')
|
|
|
|
@mock.patch('pungi.phases.extra_isos.get_dir_from_scm')
|
|
|
|
class GetExtraFilesTest(helpers.PungiTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(GetExtraFilesTest, self).setUp()
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
self.variant = self.compose.variants['Server']
|
|
|
|
self.arch = 'x86_64'
|
2018-11-14 14:41:36 +00:00
|
|
|
self.dir = os.path.join(
|
|
|
|
self.topdir, "work", self.arch, self.variant.uid, "extra-iso-extra-files"
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-11-14 14:41:36 +00:00
|
|
|
def test_no_config(self, get_dir, get_file, write_extra):
|
2018-05-09 13:39:36 +00:00
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [])
|
|
|
|
|
|
|
|
self.assertEqual(get_dir.call_args_list, [])
|
|
|
|
self.assertEqual(get_file.call_args_list, [])
|
2018-11-14 14:41:36 +00:00
|
|
|
self.assertEqual(write_extra.call_args_list, [])
|
2018-05-09 13:39:36 +00:00
|
|
|
|
2018-11-14 14:41:36 +00:00
|
|
|
def test_get_file(self, get_dir, get_file, write_extra):
|
|
|
|
get_file.return_value = ["GPL"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
|
|
|
'scm': 'git',
|
|
|
|
'repo': 'https://pagure.io/pungi.git',
|
|
|
|
'file': 'GPL',
|
|
|
|
'target': 'legalese',
|
|
|
|
}
|
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [cfg])
|
|
|
|
|
|
|
|
self.assertEqual(get_dir.call_args_list, [])
|
2018-11-14 14:41:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
get_file.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
cfg, os.path.join(self.dir, "legalese"), logger=self.compose._logger
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
write_extra.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.dir,
|
|
|
|
["legalese/GPL"],
|
|
|
|
self.compose.conf["media_checksums"],
|
|
|
|
logger=self.compose._logger,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_get_dir(self, get_dir, get_file, write_extra):
|
|
|
|
get_dir.return_value = ["a", "b"]
|
2018-05-09 13:39:36 +00:00
|
|
|
cfg = {
|
|
|
|
'scm': 'git',
|
|
|
|
'repo': 'https://pagure.io/pungi.git',
|
|
|
|
'dir': 'docs',
|
|
|
|
'target': 'foo',
|
|
|
|
}
|
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [cfg])
|
|
|
|
|
|
|
|
self.assertEqual(get_file.call_args_list, [])
|
2018-11-14 14:41:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
get_dir.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
cfg, os.path.join(self.dir, "foo"), logger=self.compose._logger
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
write_extra.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.dir,
|
|
|
|
["foo/a", "foo/b"],
|
|
|
|
self.compose.conf["media_checksums"],
|
|
|
|
logger=self.compose._logger,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_get_multiple_files(self, get_dir, get_file, write_extra):
|
|
|
|
get_file.side_effect = [["GPL"], ["setup.py"]]
|
|
|
|
cfg1 = {
|
|
|
|
'scm': 'git',
|
|
|
|
'repo': 'https://pagure.io/pungi.git',
|
|
|
|
'file': 'GPL',
|
|
|
|
'target': 'legalese',
|
|
|
|
}
|
|
|
|
cfg2 = {"scm": "git", "repo": "https://pagure.io/pungi.git", "file": "setup.py"}
|
|
|
|
extra_isos.get_extra_files(self.compose, self.variant, self.arch, [cfg1, cfg2])
|
|
|
|
|
|
|
|
self.assertEqual(get_dir.call_args_list, [])
|
|
|
|
self.assertEqual(
|
|
|
|
get_file.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
cfg1,
|
|
|
|
os.path.join(self.dir, "legalese"),
|
|
|
|
logger=self.compose._logger,
|
|
|
|
),
|
|
|
|
mock.call(cfg2, self.dir, logger=self.compose._logger),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
write_extra.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.dir,
|
|
|
|
["legalese/GPL", "setup.py"],
|
|
|
|
self.compose.conf["media_checksums"],
|
|
|
|
logger=self.compose._logger,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
@mock.patch("pungi.phases.extra_isos.tweak_treeinfo")
|
2018-05-09 13:39:36 +00:00
|
|
|
@mock.patch('pungi.wrappers.iso.write_graft_points')
|
|
|
|
@mock.patch('pungi.wrappers.iso.get_graft_points')
|
|
|
|
class GetIsoContentsTest(helpers.PungiTestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(GetIsoContentsTest, self).setUp()
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
self.variant = self.compose.variants['Server']
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
def test_non_bootable_binary(self, ggp, wgp, tt):
|
2018-05-09 13:39:36 +00:00
|
|
|
gp = {
|
|
|
|
'compose/Client/x86_64/os/Packages': {'f/foo.rpm': '/mnt/f/foo.rpm'},
|
|
|
|
'compose/Client/x86_64/os/repodata': {'primary.xml': '/mnt/repodata/primary.xml'},
|
|
|
|
'compose/Server/x86_64/os/Packages': {'b/bar.rpm': '/mnt/b/bar.rpm'},
|
|
|
|
'compose/Server/x86_64/os/repodata': {'repomd.xml': '/mnt/repodata/repomd.xml'},
|
|
|
|
'work/x86_64/Server/extra-iso-extra-files': {'EULA': '/mnt/EULA'},
|
|
|
|
}
|
|
|
|
|
|
|
|
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]]
|
|
|
|
gp_file = os.path.join(self.topdir, 'work/x86_64/iso/my.iso-graft-points')
|
|
|
|
|
|
|
|
self.assertEqual(
|
2018-11-09 09:29:28 +00:00
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
|
|
|
'x86_64',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
|
|
|
False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
gp_file,
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
expected = {
|
|
|
|
'Client/Packages/f/foo.rpm': '/mnt/f/foo.rpm',
|
|
|
|
'Client/repodata/primary.xml': '/mnt/repodata/primary.xml',
|
|
|
|
'EULA': '/mnt/EULA',
|
|
|
|
'Server/Packages/b/bar.rpm': '/mnt/b/bar.rpm',
|
|
|
|
'Server/repodata/repomd.xml': '/mnt/repodata/repomd.xml',
|
|
|
|
}
|
|
|
|
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ggp.call_args_list,
|
|
|
|
[mock.call([os.path.join(self.topdir, x)]) for x in gp]
|
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][1], {'exclude': ["*/lost+found", "*/boot.iso"]})
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.treeinfo",
|
|
|
|
)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-11-09 09:29:28 +00:00
|
|
|
def test_inherit_extra_files(self, ggp, wgp, tt):
|
|
|
|
gp = {
|
|
|
|
"compose/Client/x86_64/os/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
|
|
|
"compose/Client/x86_64/os/repodata": {"primary.xml": "/mnt/repodata/primary.xml"},
|
|
|
|
"compose/Server/x86_64/os/Packages": {"b/bar.rpm": "/mnt/b/bar.rpm"},
|
|
|
|
"compose/Server/x86_64/os/repodata": {"repomd.xml": "/mnt/repodata/repomd.xml"},
|
|
|
|
"work/x86_64/Client/extra-files": {"GPL": "/mnt/GPL"},
|
|
|
|
"work/x86_64/Server/extra-files": {"AUTHORS": "/mnt/AUTHORS"},
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files": {"EULA": "/mnt/EULA"},
|
|
|
|
}
|
|
|
|
|
|
|
|
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]]
|
|
|
|
gp_file = os.path.join(self.topdir, "work/x86_64/iso/my.iso-graft-points")
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
|
|
|
"x86_64",
|
|
|
|
["Client"],
|
|
|
|
"my.iso",
|
|
|
|
False,
|
|
|
|
inherit_extra_files=True,
|
|
|
|
),
|
|
|
|
gp_file,
|
|
|
|
)
|
|
|
|
|
|
|
|
expected = {
|
|
|
|
"Client/GPL": "/mnt/GPL",
|
|
|
|
"Client/Packages/f/foo.rpm": "/mnt/f/foo.rpm",
|
|
|
|
"Client/repodata/primary.xml": "/mnt/repodata/primary.xml",
|
|
|
|
"EULA": "/mnt/EULA",
|
|
|
|
"Server/AUTHORS": "/mnt/AUTHORS",
|
|
|
|
"Server/Packages/b/bar.rpm": "/mnt/b/bar.rpm",
|
|
|
|
"Server/repodata/repomd.xml": "/mnt/repodata/repomd.xml",
|
|
|
|
}
|
|
|
|
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ggp.call_args_list,
|
|
|
|
[mock.call([os.path.join(self.topdir, x)]) for x in gp]
|
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][1], {"exclude": ["*/lost+found", "*/boot.iso"]})
|
|
|
|
|
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.treeinfo",
|
|
|
|
)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
def test_source(self, ggp, wgp, tt):
|
2018-05-09 13:39:36 +00:00
|
|
|
gp = {
|
|
|
|
'compose/Client/source/tree/Packages': {'f/foo.rpm': '/mnt/f/foo.rpm'},
|
|
|
|
'compose/Client/source/tree/repodata': {'primary.xml': '/mnt/repodata/primary.xml'},
|
|
|
|
'compose/Server/source/tree/Packages': {'b/bar.rpm': '/mnt/b/bar.rpm'},
|
|
|
|
'compose/Server/source/tree/repodata': {'repomd.xml': '/mnt/repodata/repomd.xml'},
|
|
|
|
'work/src/Server/extra-iso-extra-files': {'EULA': '/mnt/EULA'},
|
|
|
|
}
|
|
|
|
|
|
|
|
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]]
|
|
|
|
gp_file = os.path.join(self.topdir, 'work/src/iso/my.iso-graft-points')
|
|
|
|
|
|
|
|
self.assertEqual(
|
2018-11-09 09:29:28 +00:00
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
|
|
|
'src',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
|
|
|
bootable=False,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
gp_file,
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
expected = {
|
|
|
|
'Client/Packages/f/foo.rpm': '/mnt/f/foo.rpm',
|
|
|
|
'Client/repodata/primary.xml': '/mnt/repodata/primary.xml',
|
|
|
|
'EULA': '/mnt/EULA',
|
|
|
|
'Server/Packages/b/bar.rpm': '/mnt/b/bar.rpm',
|
|
|
|
'Server/repodata/repomd.xml': '/mnt/repodata/repomd.xml',
|
|
|
|
}
|
|
|
|
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ggp.call_args_list,
|
|
|
|
[mock.call([os.path.join(self.topdir, x)]) for x in gp]
|
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][1], {'exclude': ["*/lost+found", "*/boot.iso"]})
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/source/tree/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/src/Server/extra-iso-extra-files/.treeinfo",
|
|
|
|
)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_bootable(self, ggp, wgp, tt):
|
2018-05-09 13:39:36 +00:00
|
|
|
self.compose.conf['buildinstall_method'] = 'lorax'
|
|
|
|
|
|
|
|
bi_dir = os.path.join(self.topdir, 'work/x86_64/buildinstall/Server')
|
|
|
|
iso_dir = os.path.join(self.topdir, 'work/x86_64/iso/my.iso')
|
|
|
|
helpers.touch(os.path.join(bi_dir, 'isolinux/isolinux.bin'))
|
|
|
|
helpers.touch(os.path.join(bi_dir, 'images/boot.img'))
|
2018-10-11 13:24:09 +00:00
|
|
|
helpers.touch(os.path.join(bi_dir, 'images/efiboot.img'))
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
gp = {
|
|
|
|
'compose/Client/x86_64/os/Packages': {'f/foo.rpm': '/mnt/f/foo.rpm'},
|
|
|
|
'compose/Client/x86_64/os/repodata': {'primary.xml': '/mnt/repodata/primary.xml'},
|
|
|
|
'compose/Server/x86_64/os/Packages': {'b/bar.rpm': '/mnt/b/bar.rpm'},
|
|
|
|
'compose/Server/x86_64/os/repodata': {'repomd.xml': '/mnt/repodata/repomd.xml'},
|
|
|
|
'work/x86_64/Server/extra-iso-extra-files': {'EULA': '/mnt/EULA'},
|
|
|
|
}
|
|
|
|
bi_gp = {
|
|
|
|
'isolinux/isolinux.bin': os.path.join(iso_dir, 'isolinux/isolinux.bin'),
|
|
|
|
'images/boot.img': os.path.join(iso_dir, 'images/boot.img'),
|
2018-10-11 13:24:09 +00:00
|
|
|
'images/efiboot.img': os.path.join(iso_dir, 'images/efiboot.img'),
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ggp.side_effect = lambda x: gp[x[0][len(self.topdir) + 1:]] if len(x) == 1 else bi_gp
|
|
|
|
gp_file = os.path.join(self.topdir, 'work/x86_64/iso/my.iso-graft-points')
|
|
|
|
|
|
|
|
self.assertEqual(
|
2018-07-19 12:47:06 +00:00
|
|
|
extra_isos.get_iso_contents(
|
|
|
|
self.compose,
|
|
|
|
self.variant,
|
|
|
|
'x86_64',
|
|
|
|
['Client'],
|
|
|
|
'my.iso',
|
2018-11-09 09:29:28 +00:00
|
|
|
bootable=True,
|
|
|
|
inherit_extra_files=False,
|
|
|
|
),
|
|
|
|
gp_file,
|
2018-05-09 13:39:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.maxDiff = None
|
|
|
|
|
|
|
|
expected = {
|
|
|
|
'Client/Packages/f/foo.rpm': '/mnt/f/foo.rpm',
|
|
|
|
'Client/repodata/primary.xml': '/mnt/repodata/primary.xml',
|
|
|
|
'EULA': '/mnt/EULA',
|
|
|
|
'Server/Packages/b/bar.rpm': '/mnt/b/bar.rpm',
|
|
|
|
'Server/repodata/repomd.xml': '/mnt/repodata/repomd.xml',
|
|
|
|
'isolinux/isolinux.bin': os.path.join(iso_dir, 'isolinux/isolinux.bin'),
|
|
|
|
'images/boot.img': os.path.join(iso_dir, 'images/boot.img'),
|
2018-10-11 13:24:09 +00:00
|
|
|
'images/efiboot.img': os.path.join(
|
|
|
|
self.topdir, 'compose', self.variant.uid, 'x86_64/os/images/efiboot.img',
|
|
|
|
),
|
2018-05-09 13:39:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self.assertItemsEqual(
|
|
|
|
ggp.call_args_list,
|
|
|
|
[mock.call([os.path.join(self.topdir, x)]) for x in gp] + [mock.call([bi_dir, iso_dir])]
|
|
|
|
)
|
|
|
|
self.assertEqual(len(wgp.call_args_list), 1)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][0][0], gp_file)
|
|
|
|
self.assertDictEqual(dict(wgp.call_args_list[0][0][1]), expected)
|
|
|
|
self.assertEqual(wgp.call_args_list[0][1], {'exclude': ["*/lost+found", "*/boot.iso"]})
|
|
|
|
|
|
|
|
# Check files were copied to temp directory
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(iso_dir, 'isolinux/isolinux.bin')))
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(iso_dir, 'images/boot.img')))
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
# Check correct call to tweak_treeinfo
|
|
|
|
self.assertEqual(
|
|
|
|
tt.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.compose,
|
|
|
|
["Client"],
|
|
|
|
os.path.join(self.topdir, "compose/Server/x86_64/os/.treeinfo"),
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.treeinfo",
|
|
|
|
)
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-05-09 13:39:36 +00:00
|
|
|
|
|
|
|
class GetFilenameTest(helpers.PungiTestCase):
|
|
|
|
def test_use_original_name(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
fn = extra_isos.get_filename(compose, compose.variants['Server'], 'x86_64',
|
|
|
|
'foo-{variant}-{arch}-{filename}')
|
|
|
|
|
|
|
|
self.assertEqual(fn, 'foo-Server-x86_64-image-name')
|
|
|
|
|
|
|
|
def test_use_default_without_format(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
fn = extra_isos.get_filename(compose, compose.variants['Server'], 'x86_64',
|
|
|
|
None)
|
|
|
|
|
|
|
|
self.assertEqual(fn, 'image-name')
|
|
|
|
|
|
|
|
def test_reports_unknown_placeholder(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
extra_isos.get_filename(compose, compose.variants['Server'], 'x86_64',
|
|
|
|
'foo-{boom}')
|
|
|
|
|
|
|
|
self.assertIn('boom', str(ctx.exception))
|
|
|
|
|
|
|
|
|
|
|
|
class GetVolumeIDTest(helpers.PungiTestCase):
|
|
|
|
def test_use_original_volume_id(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
volid = extra_isos.get_volume_id(compose, compose.variants['Server'],
|
|
|
|
'x86_64',
|
|
|
|
'f-{volid}')
|
|
|
|
|
|
|
|
self.assertEqual(volid, 'f-test-1.0 Server.x86_64')
|
|
|
|
|
|
|
|
def test_falls_back_to_shorter(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
volid = extra_isos.get_volume_id(compose, compose.variants['Server'],
|
|
|
|
'x86_64',
|
|
|
|
['long-foobar-{volid}', 'f-{volid}'])
|
|
|
|
|
|
|
|
self.assertEqual(volid, 'f-test-1.0 Server.x86_64')
|
|
|
|
|
|
|
|
def test_reports_unknown_placeholder(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
extra_isos.get_volume_id(compose, compose.variants['Server'],
|
|
|
|
'x86_64', 'f-{boom}')
|
|
|
|
|
|
|
|
self.assertIn('boom', str(ctx.exception))
|
|
|
|
|
|
|
|
|
2018-07-19 12:47:06 +00:00
|
|
|
class TweakTreeinfoTest(helpers.PungiTestCase):
|
|
|
|
def test_tweak(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
2018-08-15 12:57:43 +00:00
|
|
|
input = os.path.join(helpers.FIXTURE_DIR, "extraiso.treeinfo")
|
2018-07-19 12:47:06 +00:00
|
|
|
output = os.path.join(self.topdir, "actual-treeinfo")
|
2018-08-15 12:57:43 +00:00
|
|
|
expected = os.path.join(helpers.FIXTURE_DIR, "extraiso-expected.treeinfo")
|
2018-07-19 12:47:06 +00:00
|
|
|
extra_isos.tweak_treeinfo(compose, ["Client"], input, output)
|
|
|
|
|
2018-10-11 08:15:08 +00:00
|
|
|
self.assertFilesEqual(output, expected)
|
2018-07-19 12:47:06 +00:00
|
|
|
|
|
|
|
|
2018-10-17 12:06:43 +00:00
|
|
|
class PrepareMetadataTest(helpers.PungiTestCase):
|
|
|
|
@mock.patch("pungi.metadata.create_media_repo")
|
|
|
|
@mock.patch("pungi.metadata.create_discinfo")
|
|
|
|
@mock.patch("pungi.metadata.get_description")
|
|
|
|
def test_write_files(self, get_description, create_discinfo, create_media_repo):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
variant = compose.variants["Server"]
|
|
|
|
arch = "x86_64"
|
|
|
|
|
|
|
|
extra_isos.prepare_media_metadata(compose, variant, arch)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
get_description.call_args_list, [mock.call(compose, variant, arch)]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
create_discinfo.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/.discinfo",
|
|
|
|
),
|
|
|
|
get_description.return_value,
|
|
|
|
arch,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
create_media_repo.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
os.path.join(
|
|
|
|
self.topdir,
|
|
|
|
"work/x86_64/Server/extra-iso-extra-files/media.repo",
|
|
|
|
),
|
|
|
|
get_description.return_value,
|
|
|
|
timestamp=None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-09 13:39:36 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|