Debian Codegraph @

test/unit/container/wsl_test.py

raw
1 from unittest.mock import (
2 patch, Mock
3 )
4
5 from kiwi.container.wsl import ContainerImageWsl
6
7
8 class TestContainerImageWsl:
9 def setup(self):
10 self.wsl = ContainerImageWsl('root_dir')
11
12 def setup_method(self, cls):
13 self.setup()
14
15 @patch('kiwi.container.wsl.ArchiveTar')
16 @patch('kiwi.container.wsl.Compress')
17 @patch('kiwi.container.wsl.Defaults.get_exclude_list_for_root_data_sync')
18 @patch('kiwi.container.wsl.Defaults.get_exclude_list_from_custom_exclude_files')
19 @patch('kiwi.container.wsl.Command.run')
20 def test_create(
21 self, mock_Command_run,
22 mock_get_exclude_list_from_custom_exclude_files,
23 mock_get_exclude_list_for_root_data_sync,
24 mock_Compress, mock_ArchiveTar
25 ):
26 archive = Mock()
27 mock_ArchiveTar.return_value = archive
28 compress = Mock()
29 mock_Compress.return_value = compress
30
31 self.wsl.create('target_dir/image.wsl')
32 mock_ArchiveTar.assert_called_once_with(
33 'target_dir/image.wsl'
34 )
35 archive.create.assert_called_once_with(
36 'root_dir',
37 exclude=mock_get_exclude_list_for_root_data_sync.
38 return_value + mock_get_exclude_list_from_custom_exclude_files.
39 return_value,
40 options=['--numeric-owner', '--absolute-names']
41 )
42 mock_Compress.assert_called_once_with(
43 archive.create.return_value
44 )
45 compress.gzip.assert_called_once_with()
46 mock_Command_run.assert_called_once_with(
47 ['mv', compress.gzip.return_value, 'target_dir/image.wsl']
48 )