class TestFileSystemIsoFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['create_options'] == [] assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') def test_create_on_file(self, mock_iso, mock_command): iso = mock.Mock() iso.header_end_name = 'header_end' iso.get_iso_creation_parameters = mock.Mock(return_value=['args']) mock_iso.return_value = iso self.isofs.create_on_file('myimage', None) iso.init_iso_creation_parameters.assert_called_once_with([]) iso.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with('myimage') mock_command.call_args_list == [ call(['genisoimage', 'args', '-o', 'myimage', 'root_dir']), call([ 'genisoimage', '-hide', 'header_end', '-hide-joliet', 'header_end', 'args', '-o', 'myimage', 'root_dir' ]) ] iso.relocate_boot_catalog.assert_called_once_with('myimage') iso.fix_boot_catalog.assert_called_once_with('myimage')
class TestFileSystemIsoFs: @fixture(autouse=True) def inject_fixtures(self, caplog): self._caplog = caplog @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['meta_data'] == {} assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @patch('kiwi.filesystem.isofs.IsoTools') @patch('kiwi.filesystem.isofs.Iso') def test_create_on_file(self, mock_iso, mock_cdrtools): iso_tool = mock.Mock() iso_tool.has_iso_hybrid_capability = mock.Mock(return_value=False) iso_tool.get_tool_name = mock.Mock(return_value='/usr/bin/mkisofs') iso = mock.Mock() iso.header_end_name = 'header_end' mock_cdrtools.new.return_value = iso_tool mock_iso.return_value = iso self.isofs.create_on_file('myimage', None) iso.setup_isolinux_boot_path.assert_called_once_with() iso.create_header_end_marker.assert_called_once_with() iso_tool.init_iso_creation_parameters.assert_called_once_with({}) iso_tool.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with('myimage') assert iso_tool.create_iso.call_args_list == [ call('myimage'), call('myimage', hidden_files=['header_end']) ] iso.relocate_boot_catalog.assert_called_once_with('myimage') iso.fix_boot_catalog.assert_called_once_with('myimage') iso.create_hybrid.assert_called_once_with( iso.create_header_end_block.return_value, '0xffffffff', 'myimage') @patch('kiwi.filesystem.isofs.IsoTools') @patch('kiwi.filesystem.isofs.Iso') def test_create_on_file_EFI_enabled(self, mock_iso, mock_cdrtools): iso_tool = mock.Mock() iso_tool.has_iso_hybrid_capability = mock.Mock(return_value=False) iso_tool.get_tool_name = mock.Mock(return_value='/usr/bin/mkisofs') iso = mock.Mock() iso.header_end_name = 'header_end' mock_cdrtools.new.return_value = iso_tool mock_iso.return_value = iso self.isofs.custom_args['meta_data']['efi_mode'] = 'uefi' with self._caplog.at_level(logging.WARNING): self.isofs.create_on_file('myimage') iso_tool.create_iso.assert_called_once_with('myimage')
class TestFileSystemIsoFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['meta_data'] == {} assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @patch('kiwi.filesystem.isofs.IsoTools') @patch('kiwi.filesystem.isofs.Iso') def test_create_on_file(self, mock_iso, mock_cdrtools): iso_tool = mock.Mock() iso_tool.has_iso_hybrid_capability = mock.Mock( return_value=False ) iso_tool.get_tool_name = mock.Mock( return_value='/usr/bin/mkisofs' ) iso = mock.Mock() iso.header_end_name = 'header_end' mock_cdrtools.return_value = iso_tool mock_iso.return_value = iso self.isofs.create_on_file('myimage', None) iso.setup_isolinux_boot_path.assert_called_once_with() iso.create_header_end_marker.assert_called_once_with() iso_tool.init_iso_creation_parameters.assert_called_once_with({}) iso_tool.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with('myimage') assert iso_tool.create_iso.call_args_list == [ call('myimage'), call('myimage', hidden_files=['header_end']) ] iso.relocate_boot_catalog.assert_called_once_with( 'myimage' ) iso.fix_boot_catalog.assert_called_once_with( 'myimage' ) iso.create_hybrid.assert_called_once_with( iso.create_header_end_block.return_value, '0xffffffff', 'myimage', False )
class TestFileSystemIsoFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['meta_data'] == {} assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @patch('kiwi.filesystem.isofs.IsoTools') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.platform.machine') def test_create_on_file(self, mock_platform_machine, mock_iso, mock_cdrtools): mock_platform_machine.return_value = 'x86_64' iso_tool = mock.Mock() iso_tool.has_iso_hybrid_capability = mock.Mock(return_value=False) iso_tool.get_tool_name = mock.Mock(return_value='/usr/bin/mkisofs') iso = mock.Mock() iso.header_end_name = 'header_end' mock_cdrtools.return_value = iso_tool mock_iso.return_value = iso self.isofs.create_on_file('myimage', None) iso.setup_isolinux_boot_path.assert_called_once_with() iso.create_header_end_marker.assert_called_once_with() iso_tool.init_iso_creation_parameters.assert_called_once_with({}) iso_tool.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with('myimage') assert iso_tool.create_iso.call_args_list == [ call('myimage'), call('myimage', hidden_files=['header_end']) ] iso.relocate_boot_catalog.assert_called_once_with('myimage') iso.fix_boot_catalog.assert_called_once_with('myimage') iso.create_hybrid.assert_called_once_with( iso.create_header_end_block.return_value, '0xffffffff', 'myimage', False)
class TestFileSystemIsoFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['create_options'] == [] assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') def test_create_on_file(self, mock_iso, mock_command): iso = mock.Mock() iso.header_end_name = 'header_end' iso.get_iso_creation_parameters = mock.Mock( return_value=['args'] ) mock_iso.return_value = iso self.isofs.create_on_file('myimage', None) iso.init_iso_creation_parameters.assert_called_once_with([]) iso.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with( 'myimage' ) mock_command.call_args_list == [ call([ 'genisoimage', 'args', '-o', 'myimage', 'root_dir' ]), call([ 'genisoimage', '-hide', 'header_end', '-hide-joliet', 'header_end', 'args', '-o', 'myimage', 'root_dir' ]) ] iso.relocate_boot_catalog.assert_called_once_with( 'myimage' ) iso.fix_boot_catalog.assert_called_once_with( 'myimage' )
class TestFileSystemIsoFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['create_options'] == [] assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @raises(KiwiIsoToolError) @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.Path.which') def test_create_on_file_no_tool_found(self, mock_which, mock_iso, mock_command): mock_which.return_value = None self.isofs.create_on_file('myimage', None) @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.Path.which') def test_create_on_file_mkisofs(self, mock_which, mock_iso, mock_command): iso = mock.Mock() iso.header_end_name = 'header_end' iso.get_iso_creation_parameters = mock.Mock(return_value=['args']) mock_iso.return_value = iso path_return_values = ['/usr/bin/mkisofs', '/usr/bin/mkisofs'] def side_effect(arg): return path_return_values.pop() mock_which.side_effect = side_effect self.isofs.create_on_file('myimage', None) iso.init_iso_creation_parameters.assert_called_once_with([]) iso.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with('myimage') assert mock_command.call_args_list == [ call(['/usr/bin/mkisofs', 'args', '-o', 'myimage', 'root_dir']), call([ '/usr/bin/mkisofs', '-hide', 'header_end', '-hide-joliet', 'header_end', 'args', '-o', 'myimage', 'root_dir' ]) ] iso.relocate_boot_catalog.assert_called_once_with('myimage') iso.fix_boot_catalog.assert_called_once_with('myimage') @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.Path.which') def test_create_on_file_genisoimage(self, mock_which, mock_iso, mock_command): iso = mock.Mock() iso.header_end_name = 'header_end' iso.get_iso_creation_parameters = mock.Mock(return_value=['args']) mock_iso.return_value = iso path_return_values = [ '/usr/bin/genisoimage', None, '/usr/bin/genisoimage', None ] def side_effect(arg): return path_return_values.pop() mock_which.side_effect = side_effect self.isofs.create_on_file('myimage', None) iso.init_iso_creation_parameters.assert_called_once_with([]) iso.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with('myimage') assert mock_command.call_args_list == [ call(['/usr/bin/genisoimage', 'args', '-o', 'myimage', 'root_dir']), call([ '/usr/bin/genisoimage', '-hide', 'header_end', '-hide-joliet', 'header_end', 'args', '-o', 'myimage', 'root_dir' ]) ] iso.relocate_boot_catalog.assert_called_once_with('myimage') iso.fix_boot_catalog.assert_called_once_with('myimage')
class TestFileSystemIsoFs(object): @patch('os.path.exists') def setup(self, mock_exists): mock_exists.return_value = True self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir') def test_post_init(self): self.isofs.post_init({'some_args': 'data'}) assert self.isofs.custom_args['create_options'] == [] assert self.isofs.custom_args['mount_options'] == [] assert self.isofs.custom_args['some_args'] == 'data' @raises(KiwiIsoToolError) @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.Path.which') def test_create_on_file_no_tool_found( self, mock_which, mock_iso, mock_command ): mock_which.return_value = None self.isofs.create_on_file('myimage', None) @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.Path.which') def test_create_on_file_mkisofs( self, mock_which, mock_iso, mock_command ): iso = mock.Mock() iso.header_end_name = 'header_end' iso.get_iso_creation_parameters = mock.Mock( return_value=['args'] ) mock_iso.return_value = iso path_return_values = [ '/usr/bin/mkisofs', '/usr/bin/mkisofs' ] def side_effect(arg): return path_return_values.pop() mock_which.side_effect = side_effect self.isofs.create_on_file('myimage', None) iso.init_iso_creation_parameters.assert_called_once_with([]) iso.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with( 'myimage' ) assert mock_command.call_args_list == [ call([ '/usr/bin/mkisofs', 'args', '-o', 'myimage', 'root_dir' ]), call([ '/usr/bin/mkisofs', '-hide', 'header_end', '-hide-joliet', 'header_end', 'args', '-o', 'myimage', 'root_dir' ]) ] iso.relocate_boot_catalog.assert_called_once_with( 'myimage' ) iso.fix_boot_catalog.assert_called_once_with( 'myimage' ) @patch('kiwi.filesystem.isofs.Command.run') @patch('kiwi.filesystem.isofs.Iso') @patch('kiwi.filesystem.isofs.Path.which') def test_create_on_file_genisoimage( self, mock_which, mock_iso, mock_command ): iso = mock.Mock() iso.header_end_name = 'header_end' iso.get_iso_creation_parameters = mock.Mock( return_value=['args'] ) mock_iso.return_value = iso path_return_values = [ '/usr/bin/genisoimage', None, '/usr/bin/genisoimage', None ] def side_effect(arg): return path_return_values.pop() mock_which.side_effect = side_effect self.isofs.create_on_file('myimage', None) iso.init_iso_creation_parameters.assert_called_once_with([]) iso.add_efi_loader_parameters.assert_called_once_with() iso.create_header_end_block.assert_called_once_with( 'myimage' ) assert mock_command.call_args_list == [ call([ '/usr/bin/genisoimage', 'args', '-o', 'myimage', 'root_dir' ]), call([ '/usr/bin/genisoimage', '-hide', 'header_end', '-hide-joliet', 'header_end', 'args', '-o', 'myimage', 'root_dir' ]) ] iso.relocate_boot_catalog.assert_called_once_with( 'myimage' ) iso.fix_boot_catalog.assert_called_once_with( 'myimage' )