Debian Codegraph @

test/unit/storage/subformat/vhd_test.py

raw
1 from unittest.mock import (
2 patch, Mock
3 )
4
5 import kiwi
6
7 from kiwi.defaults import Defaults
8 from kiwi.storage.subformat.vhd import DiskFormatVhd
9
10
11 class TestDiskFormatVhd:
12 def setup(self):
13 Defaults.set_platform_name('x86_64')
14 xml_data = Mock()
15 xml_data.get_name = Mock(
16 return_value='some-disk-image'
17 )
18 self.xml_state = Mock()
19 self.xml_state.xml_data = xml_data
20 self.xml_state.get_image_version = Mock(
21 return_value='1.2.3'
22 )
23 self.runtime_config = Mock()
24 self.runtime_config.get_bundle_compression.return_value = False
25 kiwi.storage.subformat.base.RuntimeConfig = Mock(
26 return_value=self.runtime_config
27 )
28 self.disk_format = DiskFormatVhd(
29 self.xml_state, 'root_dir', 'target_dir'
30 )
31
32 def setup_method(self, cls):
33 self.setup()
34
35 def test_post_init(self):
36 self.disk_format.post_init({'option': 'value'})
37 assert self.disk_format.options == ['-o', 'option=value']
38
39 @patch('kiwi.storage.subformat.vhd.Command.run')
40 def test_create_image_format(self, mock_command):
41 self.disk_format.create_image_format()
42 mock_command.assert_called_once_with(
43 [
44 'qemu-img', 'convert', '-f', 'raw',
45 'target_dir/some-disk-image.x86_64-1.2.3.raw', '-O', 'vpc',
46 'target_dir/some-disk-image.x86_64-1.2.3.vhd'
47 ]
48 )