"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ironic/tests/unit/common/test_images.py" between
ironic-16.0.2.tar.gz and ironic-16.0.3.tar.gz

About: OpenStack Ironic (Optional Service: Bare-Metal Provisioning) aims to provision bare metal machines instead of virtual machines, forked from the Nova baremetal driver.
The "Victoria" series (latest release).

test_images.py  (ironic-16.0.2):test_images.py  (ironic-16.0.3)
skipping to change at line 251 skipping to change at line 251
mock_igi.return_value = False mock_igi.return_value = False
instance_info = {'image_source': 'whole_disk_image'} instance_info = {'image_source': 'whole_disk_image'}
is_whole_disk_image = images.is_whole_disk_image('context', is_whole_disk_image = images.is_whole_disk_image('context',
instance_info) instance_info)
self.assertTrue(is_whole_disk_image) self.assertTrue(is_whole_disk_image)
self.assertFalse(mock_gip.called) self.assertFalse(mock_gip.called)
mock_igi.assert_called_once_with(instance_info['image_source']) mock_igi.assert_called_once_with(instance_info['image_source'])
class FsImageTestCase(base.TestCase): class FsImageTestCase(base.TestCase):
@mock.patch.object(builtins, 'open', autospec=True)
@mock.patch.object(shutil, 'copyfile', autospec=True) @mock.patch.object(shutil, 'copyfile', autospec=True)
@mock.patch.object(os, 'makedirs', autospec=True) @mock.patch.object(os, 'makedirs', autospec=True)
@mock.patch.object(os.path, 'dirname', autospec=True) def test__create_root_fs(self, mkdir_mock, cp_mock, open_mock):
@mock.patch.object(os.path, 'exists', autospec=True)
def test__create_root_fs(self, path_exists_mock,
dirname_mock, mkdir_mock, cp_mock):
def path_exists_mock_func(path):
return path == 'root_dir'
files_info = { files_info = {
'a1': 'b1', 'a1': 'b1',
'a2': 'b2', 'a2': 'b2',
'a3': 'sub_dir/b3'} 'a3': 'sub_dir/b3',
b'a4': 'b4'}
path_exists_mock.side_effect = path_exists_mock_func
dirname_mock.side_effect = ['root_dir', 'root_dir', 'root_dir/sub_dir',
'root_dir/sub_dir']
images._create_root_fs('root_dir', files_info) images._create_root_fs('root_dir', files_info)
cp_mock.assert_any_call('a1', 'root_dir/b1') cp_mock.assert_any_call('a1', 'root_dir/b1')
cp_mock.assert_any_call('a2', 'root_dir/b2') cp_mock.assert_any_call('a2', 'root_dir/b2')
cp_mock.assert_any_call('a3', 'root_dir/sub_dir/b3') cp_mock.assert_any_call('a3', 'root_dir/sub_dir/b3')
path_exists_mock.assert_any_call('root_dir/sub_dir') open_mock.assert_called_once_with('root_dir/b4', 'wb')
dirname_mock.assert_any_call('root_dir/b1') fp = open_mock.return_value.__enter__.return_value
dirname_mock.assert_any_call('root_dir/b2') fp.write.assert_called_once_with(b'a4')
dirname_mock.assert_any_call('root_dir/sub_dir/b3')
mkdir_mock.assert_called_once_with('root_dir/sub_dir') mkdir_mock.assert_any_call('root_dir', exist_ok=True)
mkdir_mock.assert_any_call('root_dir/sub_dir', exist_ok=True)
@mock.patch.object(images, '_create_root_fs', autospec=True) @mock.patch.object(images, '_create_root_fs', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
@mock.patch.object(utils, 'write_to_file', autospec=True) @mock.patch.object(utils, 'write_to_file', autospec=True)
@mock.patch.object(ironic_utils, 'dd', autospec=True) @mock.patch.object(ironic_utils, 'dd', autospec=True)
@mock.patch.object(utils, 'umount', autospec=True) @mock.patch.object(utils, 'umount', autospec=True)
@mock.patch.object(utils, 'mount', autospec=True) @mock.patch.object(utils, 'mount', autospec=True)
@mock.patch.object(ironic_utils, 'mkfs', autospec=True) @mock.patch.object(ironic_utils, 'mkfs', autospec=True)
def test_create_vfat_image( def test_create_vfat_image(
self, mkfs_mock, mount_mock, umount_mock, dd_mock, write_mock, self, mkfs_mock, mount_mock, umount_mock, dd_mock, write_mock,
skipping to change at line 414 skipping to change at line 408
"menuentry \"boot_partition\" {\n" "menuentry \"boot_partition\" {\n"
"linuxefi /vmlinuz key1=value1 key2 --\n" "linuxefi /vmlinuz key1=value1 key2 --\n"
"initrdefi /initrd\n" "initrdefi /initrd\n"
"}") "}")
cfg = images._generate_cfg(kernel_params, cfg = images._generate_cfg(kernel_params,
CONF.grub_config_template, CONF.grub_config_template,
options) options)
self.assertEqual(expected_cfg, cfg) self.assertEqual(expected_cfg, cfg)
@mock.patch.object(images, 'os', autospec=True)
def test__read_dir(self, mock_os):
mock_os.path.join = os.path.join
mock_os.path.isdir.side_effect = (False, True, False)
mock_os.listdir.side_effect = [['a', 'b'], ['c']]
file_info = images._read_dir('/mnt')
expected = {
'/mnt/a': 'a',
'/mnt/b/c': 'b/c'
}
self.assertEqual(expected, file_info)
@mock.patch.object(os.path, 'relpath', autospec=True) @mock.patch.object(os.path, 'relpath', autospec=True)
@mock.patch.object(os, 'walk', autospec=True) @mock.patch.object(os, 'walk', autospec=True)
@mock.patch.object(utils, 'mount', autospec=True) @mock.patch.object(utils, 'mount', autospec=True)
def test__mount_deploy_iso(self, mount_mock, def test__mount_deploy_iso(self, mount_mock,
walk_mock, relpath_mock): walk_mock, relpath_mock):
walk_mock.return_value = [('/tmpdir1/EFI/ubuntu', [], ['grub.cfg']), walk_mock.return_value = [('/tmpdir1/EFI/ubuntu', [], ['grub.cfg']),
('/tmpdir1/isolinux', [], ('/tmpdir1/isolinux', [],
['efiboot.img', 'isolinux.bin', ['efiboot.img', 'isolinux.bin',
'isolinux.cfg'])] 'isolinux.cfg'])]
relpath_mock.side_effect = ['EFI/ubuntu/grub.cfg', relpath_mock.side_effect = ['EFI/ubuntu/grub.cfg',
skipping to change at line 600 skipping to change at line 579
'boot/grub/efiboot.img', '-no-emul-boot', '-o', 'tgt_file', 'boot/grub/efiboot.img', '-no-emul-boot', '-o', 'tgt_file',
'tmpdir') 'tmpdir')
@mock.patch.object(images, '_create_root_fs', autospec=True) @mock.patch.object(images, '_create_root_fs', autospec=True)
@mock.patch.object(utils, 'write_to_file', autospec=True) @mock.patch.object(utils, 'write_to_file', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True) @mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(images, '_generate_cfg', autospec=True) @mock.patch.object(images, '_generate_cfg', autospec=True)
def _test_create_isolinux_image_for_bios( def _test_create_isolinux_image_for_bios(
self, gen_cfg_mock, execute_mock, tempdir_mock, self, gen_cfg_mock, execute_mock, tempdir_mock,
write_to_file_mock, create_root_fs_mock, ldlinux_path=None): write_to_file_mock, create_root_fs_mock, ldlinux_path=None,
inject_files=None):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
cfg = "cfg" cfg = "cfg"
cfg_file = 'tmpdir/isolinux/isolinux.cfg' cfg_file = 'tmpdir/isolinux/isolinux.cfg'
gen_cfg_mock.return_value = cfg gen_cfg_mock.return_value = cfg
params = ['a=b', 'c'] params = ['a=b', 'c']
isolinux_options = {'kernel': '/vmlinuz', isolinux_options = {'kernel': '/vmlinuz',
'ramdisk': '/initrd'} 'ramdisk': '/initrd'}
images.create_isolinux_image_for_bios('tgt_file', images.create_isolinux_image_for_bios('tgt_file',
'path/to/kernel', 'path/to/kernel',
'path/to/ramdisk', 'path/to/ramdisk',
kernel_params=params) kernel_params=params,
inject_files=inject_files)
files_info = { files_info = {
'path/to/kernel': 'vmlinuz', 'path/to/kernel': 'vmlinuz',
'path/to/ramdisk': 'initrd', 'path/to/ramdisk': 'initrd',
CONF.isolinux_bin: 'isolinux/isolinux.bin' CONF.isolinux_bin: 'isolinux/isolinux.bin'
} }
if inject_files:
files_info.update(inject_files)
if ldlinux_path: if ldlinux_path:
files_info[ldlinux_path] = 'isolinux/ldlinux.c32' files_info[ldlinux_path] = 'isolinux/ldlinux.c32'
create_root_fs_mock.assert_called_once_with('tmpdir', files_info) create_root_fs_mock.assert_called_once_with('tmpdir', files_info)
gen_cfg_mock.assert_called_once_with(params, gen_cfg_mock.assert_called_once_with(params,
CONF.isolinux_config_template, CONF.isolinux_config_template,
isolinux_options) isolinux_options)
write_to_file_mock.assert_called_once_with(cfg_file, cfg) write_to_file_mock.assert_called_once_with(cfg_file, cfg)
execute_mock.assert_called_once_with( execute_mock.assert_called_once_with(
'mkisofs', '-r', '-V', 'mkisofs', '-r', '-V',
"VMEDIA_BOOT_ISO", '-cache-inodes', '-J', '-l', "VMEDIA_BOOT_ISO", '-cache-inodes', '-J', '-l',
skipping to change at line 654 skipping to change at line 637
CONF.set_override('ldlinux_c32', 'path/to/ldlinux.c32') CONF.set_override('ldlinux_c32', 'path/to/ldlinux.c32')
self._test_create_isolinux_image_for_bios( self._test_create_isolinux_image_for_bios(
ldlinux_path='path/to/ldlinux.c32') ldlinux_path='path/to/ldlinux.c32')
@mock.patch.object(os.path, 'isfile', autospec=True) @mock.patch.object(os.path, 'isfile', autospec=True)
def test_create_isolinux_image_for_bios_default_ldlinux(self, mock_isfile): def test_create_isolinux_image_for_bios_default_ldlinux(self, mock_isfile):
mock_isfile.side_effect = [False, True] mock_isfile.side_effect = [False, True]
self._test_create_isolinux_image_for_bios( self._test_create_isolinux_image_for_bios(
ldlinux_path='/usr/share/syslinux/ldlinux.c32') ldlinux_path='/usr/share/syslinux/ldlinux.c32')
@mock.patch.object(os.path, 'isfile', autospec=True)
def test_create_isolinux_image_for_bios_inject_files(self, mock_isfile):
mock_isfile.return_value = False
self._test_create_isolinux_image_for_bios(
inject_files={'/source': 'target'})
@mock.patch.object(images, '_umount_without_raise', autospec=True) @mock.patch.object(images, '_umount_without_raise', autospec=True)
@mock.patch.object(images, '_create_root_fs', autospec=True) @mock.patch.object(images, '_create_root_fs', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True) @mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(os, 'walk', autospec=True) @mock.patch.object(os, 'walk', autospec=True)
def test_create_esp_image_uefi_rootfs_fails( def test_create_esp_image_uefi_rootfs_fails(
self, walk_mock, utils_mock, tempdir_mock, self, walk_mock, utils_mock, tempdir_mock,
create_root_fs_mock, umount_mock): create_root_fs_mock, umount_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
skipping to change at line 766 skipping to change at line 755
'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid') 'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid') 'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'deploy_iso-uuid', 'tmpdir/deploy_iso-uuid') 'ctx', 'deploy_iso-uuid', 'tmpdir/deploy_iso-uuid')
params = ['root=UUID=root-uuid', 'kernel-params'] params = ['root=UUID=root-uuid', 'kernel-params']
create_isolinux_mock.assert_called_once_with( create_isolinux_mock.assert_called_once_with(
'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid', 'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid',
deploy_iso='tmpdir/deploy_iso-uuid', deploy_iso='tmpdir/deploy_iso-uuid',
esp_image=None, kernel_params=params, configdrive=None) esp_image=None, kernel_params=params, inject_files=None)
@mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True)
@mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(images, 'fetch', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_esp_image( def test_create_boot_iso_for_uefi_esp_image(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock): self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
skipping to change at line 794 skipping to change at line 783
'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid') 'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid') 'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'efiboot-uuid', 'tmpdir/efiboot-uuid') 'ctx', 'efiboot-uuid', 'tmpdir/efiboot-uuid')
params = ['root=UUID=root-uuid', 'kernel-params'] params = ['root=UUID=root-uuid', 'kernel-params']
create_isolinux_mock.assert_called_once_with( create_isolinux_mock.assert_called_once_with(
'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid', 'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid',
deploy_iso=None, esp_image='tmpdir/efiboot-uuid', deploy_iso=None, esp_image='tmpdir/efiboot-uuid',
kernel_params=params, configdrive=None) kernel_params=params, inject_files=None)
@mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True)
@mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(images, 'fetch', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_deploy_iso_for_hrefs( def test_create_boot_iso_for_uefi_deploy_iso_for_hrefs(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock): self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
skipping to change at line 822 skipping to change at line 811
'tmpdir/kernel-href'), 'tmpdir/kernel-href'),
mock.call('ctx', 'http://ramdisk-href', mock.call('ctx', 'http://ramdisk-href',
'tmpdir/ramdisk-href'), 'tmpdir/ramdisk-href'),
mock.call('ctx', 'http://deploy_iso-href', mock.call('ctx', 'http://deploy_iso-href',
'tmpdir/deploy_iso-href')] 'tmpdir/deploy_iso-href')]
fetch_images_mock.assert_has_calls(expected_calls) fetch_images_mock.assert_has_calls(expected_calls)
params = ['root=UUID=root-uuid', 'kernel-params'] params = ['root=UUID=root-uuid', 'kernel-params']
create_isolinux_mock.assert_called_once_with( create_isolinux_mock.assert_called_once_with(
'output_file', 'tmpdir/kernel-href', 'tmpdir/ramdisk-href', 'output_file', 'tmpdir/kernel-href', 'tmpdir/ramdisk-href',
deploy_iso='tmpdir/deploy_iso-href', deploy_iso='tmpdir/deploy_iso-href',
esp_image=None, kernel_params=params, configdrive=None) esp_image=None, kernel_params=params, inject_files=None)
@mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True) @mock.patch.object(images, 'create_esp_image_for_uefi', autospec=True)
@mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(images, 'fetch', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_uefi_esp_image_for_hrefs( def test_create_boot_iso_for_uefi_esp_image_for_hrefs(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock): self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
skipping to change at line 850 skipping to change at line 839
'tmpdir/kernel-href'), 'tmpdir/kernel-href'),
mock.call('ctx', 'http://ramdisk-href', mock.call('ctx', 'http://ramdisk-href',
'tmpdir/ramdisk-href'), 'tmpdir/ramdisk-href'),
mock.call('ctx', 'http://efiboot-href', mock.call('ctx', 'http://efiboot-href',
'tmpdir/efiboot-href')] 'tmpdir/efiboot-href')]
fetch_images_mock.assert_has_calls(expected_calls) fetch_images_mock.assert_has_calls(expected_calls)
params = ['root=UUID=root-uuid', 'kernel-params'] params = ['root=UUID=root-uuid', 'kernel-params']
create_isolinux_mock.assert_called_once_with( create_isolinux_mock.assert_called_once_with(
'output_file', 'tmpdir/kernel-href', 'tmpdir/ramdisk-href', 'output_file', 'tmpdir/kernel-href', 'tmpdir/ramdisk-href',
deploy_iso=None, esp_image='tmpdir/efiboot-href', deploy_iso=None, esp_image='tmpdir/efiboot-href',
kernel_params=params, configdrive=None) kernel_params=params, inject_files=None)
@mock.patch.object(images, 'create_isolinux_image_for_bios', autospec=True) @mock.patch.object(images, 'create_isolinux_image_for_bios', autospec=True)
@mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(images, 'fetch', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_bios( def test_create_boot_iso_for_bios(
self, tempdir_mock, fetch_images_mock, create_isolinux_mock): self, tempdir_mock, fetch_images_mock, create_isolinux_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
images.create_boot_iso('ctx', 'output_file', 'kernel-uuid', images.create_boot_iso('ctx', 'output_file', 'kernel-uuid',
'ramdisk-uuid', 'deploy_iso-uuid', 'ramdisk-uuid', 'deploy_iso-uuid',
'efiboot-uuid', 'root-uuid', 'efiboot-uuid', 'root-uuid',
'kernel-params', 'bios', 'configdrive') 'kernel-params', 'bios')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid') 'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid') 'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid')
fetch_images_mock.assert_any_call(
'ctx', 'configdrive', 'tmpdir/configdrive')
# Note (NobodyCam): the original assert asserted that fetch_images # Note (NobodyCam): the original assert asserted that fetch_images
# was not called with parameters, this did not # was not called with parameters, this did not
# work, So I instead assert that there were only # work, So I instead assert that there were only
# Two calls to the mock validating the above # Two calls to the mock validating the above
# asserts. # asserts.
self.assertEqual(3, fetch_images_mock.call_count) self.assertEqual(2, fetch_images_mock.call_count)
params = ['root=UUID=root-uuid', 'kernel-params'] params = ['root=UUID=root-uuid', 'kernel-params']
create_isolinux_mock.assert_called_once_with( create_isolinux_mock.assert_called_once_with(
'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid', 'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid',
kernel_params=params, configdrive='tmpdir/configdrive') kernel_params=params, inject_files=None)
@mock.patch.object(images, 'create_isolinux_image_for_bios', autospec=True) @mock.patch.object(images, 'create_isolinux_image_for_bios', autospec=True)
@mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(images, 'fetch', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_bios_with_no_boot_mode(self, tempdir_mock, def test_create_boot_iso_for_bios_with_no_boot_mode(self, tempdir_mock,
fetch_images_mock, fetch_images_mock,
create_isolinux_mock): create_isolinux_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
images.create_boot_iso('ctx', 'output_file', 'kernel-uuid', images.create_boot_iso('ctx', 'output_file', 'kernel-uuid',
'ramdisk-uuid', 'deploy_iso-uuid', 'ramdisk-uuid', 'deploy_iso-uuid',
'efiboot-uuid', 'root-uuid', 'efiboot-uuid', 'root-uuid',
'kernel-params', None, 'http://configdrive') 'kernel-params', None)
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid') 'ctx', 'kernel-uuid', 'tmpdir/kernel-uuid')
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid') 'ctx', 'ramdisk-uuid', 'tmpdir/ramdisk-uuid')
fetch_images_mock.assert_any_call(
'ctx', 'http://configdrive', 'tmpdir/configdrive')
params = ['root=UUID=root-uuid', 'kernel-params'] params = ['root=UUID=root-uuid', 'kernel-params']
create_isolinux_mock.assert_called_once_with( create_isolinux_mock.assert_called_once_with(
'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid', 'output_file', 'tmpdir/kernel-uuid', 'tmpdir/ramdisk-uuid',
configdrive='tmpdir/configdrive', kernel_params=params) kernel_params=params, inject_files=None)
@mock.patch.object(images, 'create_isolinux_image_for_bios', autospec=True) @mock.patch.object(images, 'create_isolinux_image_for_bios', autospec=True)
@mock.patch.object(images, 'fetch', autospec=True) @mock.patch.object(images, 'fetch', autospec=True)
@mock.patch.object(utils, 'tempdir', autospec=True) @mock.patch.object(utils, 'tempdir', autospec=True)
def test_create_boot_iso_for_existing_iso(self, tempdir_mock, def test_create_boot_iso_for_existing_iso(self, tempdir_mock,
fetch_images_mock, fetch_images_mock,
create_isolinux_mock): create_isolinux_mock):
mock_file_handle = mock.MagicMock(spec=io.BytesIO) mock_file_handle = mock.MagicMock(spec=io.BytesIO)
mock_file_handle.__enter__.return_value = 'tmpdir' mock_file_handle.__enter__.return_value = 'tmpdir'
tempdir_mock.return_value = mock_file_handle tempdir_mock.return_value = mock_file_handle
base_iso = 'http://fake.local:1234/fake.iso' base_iso = 'http://fake.local:1234/fake.iso'
images.create_boot_iso('ctx', 'output_file', 'kernel-uuid', images.create_boot_iso('ctx', 'output_file', 'kernel-uuid',
'ramdisk-uuid', 'deploy_iso-uuid', 'ramdisk-uuid', 'deploy_iso-uuid',
'efiboot-uuid', None, 'efiboot-uuid', None,
None, None, 'http://configdrive', None, None, base_iso=base_iso)
base_iso=base_iso)
fetch_images_mock.assert_any_call( fetch_images_mock.assert_any_call(
'ctx', base_iso, 'output_file') 'ctx', base_iso, 'output_file')
create_isolinux_mock.assert_not_called() create_isolinux_mock.assert_not_called()
@mock.patch.object(image_service, 'get_image_service', autospec=True) @mock.patch.object(image_service, 'get_image_service', autospec=True)
def test_get_glance_image_properties_no_such_prop(self, def test_get_glance_image_properties_no_such_prop(self,
image_service_mock): image_service_mock):
 End of changes. 23 change blocks. 
49 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)