Debian Codegraph @

test/unit/filesystem/isofs_test.py

raw
1 import logging
2 from pytest import fixture
3 from unittest.mock import patch
4 import unittest.mock as mock
5
6 from kiwi.filesystem.isofs import FileSystemIsoFs
7
8
9 class TestFileSystemIsoFs:
10 @fixture(autouse=True)
11 def inject_fixtures(self, caplog):
12 self._caplog = caplog
13
14 @patch('os.path.exists')
15 def setup(self, mock_exists):
16 mock_exists.return_value = True
17 self.isofs = FileSystemIsoFs(mock.Mock(), 'root_dir')
18
19 @patch('os.path.exists')
20 def setup_method(self, cls, mock_exists):
21 self.setup()
22
23 def test_post_init(self):
24 self.isofs.post_init({'some_args': 'data'})
25 assert self.isofs.custom_args['meta_data'] == {}
26 assert self.isofs.custom_args['mount_options'] == []
27 assert self.isofs.custom_args['some_args'] == 'data'
28
29 @patch('kiwi.filesystem.isofs.IsoTools')
30 def test_create_on_file(self, mock_IsoTools):
31 iso_tool = mock.Mock()
32 iso_tool.has_iso_hybrid_capability = mock.Mock(
33 return_value=True
34 )
35 iso_tool.get_tool_name = mock.Mock(
36 return_value='/usr/bin/xorriso'
37 )
38 mock_IsoTools.new.return_value = iso_tool
39 self.isofs.create_on_file('myimage', None)
40
41 iso_tool.init_iso_creation_parameters.assert_called_once_with({})
42
43 iso_tool.create_iso.assert_called_once_with('myimage')
44
45 @patch('kiwi.filesystem.isofs.IsoTools')
46 def test_create_on_file_EFI_enabled(self, mock_IsoTools):
47 iso_tool = mock.Mock()
48 iso_tool.has_iso_hybrid_capability = mock.Mock(
49 return_value=True
50 )
51 iso_tool.get_tool_name = mock.Mock(
52 return_value='/usr/bin/xorriso'
53 )
54 mock_IsoTools.new.return_value = iso_tool
55 self.isofs.custom_args['meta_data']['efi_mode'] = 'uefi'
56 self.isofs.custom_args['meta_data']['efi_loader'] = 'esp-image-file'
57 with self._caplog.at_level(logging.WARNING):
58 self.isofs.create_on_file('myimage')
59 iso_tool.create_iso.assert_called_once_with('myimage')
60 iso_tool.add_efi_loader_parameters.assert_called_once_with(
61 'esp-image-file',
62 {'efi_mode': 'uefi', 'efi_loader': 'esp-image-file'}
63 )