Debian Codegraph @

test/unit/filesystem/erofs_test.py

raw
1 from unittest.mock import patch
2
3 import unittest.mock as mock
4
5 from kiwi.defaults import Defaults
6 from kiwi.filesystem.erofs import FileSystemEroFs
7
8
9 class TestFileSystemEroFs:
10 @patch('os.path.exists')
11 def setup(self, mock_exists):
12 mock_exists.return_value = True
13 self.erofs = FileSystemEroFs(
14 mock.Mock(), 'root_dir',
15 custom_args={'compression': 'zstd,level=21'}
16 )
17
18 @patch('os.path.exists')
19 def setup_method(self, cls, mock_exists):
20 self.setup()
21
22 @patch('kiwi.filesystem.erofs.Command.run')
23 def test_create_on_file(self, mock_command):
24 Defaults.set_platform_name('x86_64')
25 self.erofs.create_on_file('myimage', 'label')
26 mock_command.assert_called_once_with(
27 [
28 'mkfs.erofs', '-z', 'zstd,level=21',
29 '-L', 'label', 'myimage', 'root_dir'
30 ]
31 )
32
33 @patch('kiwi.filesystem.erofs.Command.run')
34 def test_create_on_file_exclude_data(self, mock_command):
35 Defaults.set_platform_name('x86_64')
36 self.erofs.create_on_file('myimage', 'label', ['foo'])
37 mock_command.assert_called_once_with(
38 [
39 'mkfs.erofs', '-z', 'zstd,level=21',
40 '-L', 'label', '--exclude-regex=^foo$',
41 'myimage', 'root_dir'
42 ]
43 )