kiwi-el8/test/unit/storage_subformat_test.py
Marcus Schäfer e6cc5bfa09 Move from nose to pytest
nose is no longer maintained, thus we have to move to another
testing system. This commit updates the tox setup and all tests
to use pytest instead of nose.
2016-03-14 12:23:14 +01:00

73 lines
2.4 KiB
Python

from mock import patch
import mock
from .test_helper import *
from kiwi.exceptions import *
from kiwi.storage.subformat import DiskFormat
class TestDiskFormat(object):
@raises(KiwiDiskFormatSetupError)
def test_format_not_implemented(self):
DiskFormat('foo', mock.Mock(), 'root_dir', 'target_dir')
@patch('kiwi.storage.subformat.DiskFormatQcow2')
def test_disk_format_qcow2(self, mock_qcow2):
xml_state = mock.Mock()
DiskFormat('qcow2', xml_state, 'root_dir', 'target_dir')
mock_qcow2.assert_called_once_with(
xml_state, 'root_dir', 'target_dir'
)
@patch('kiwi.storage.subformat.DiskFormatVhd')
def test_disk_format_vhd(self, mock_vhd):
xml_state = mock.Mock()
DiskFormat('vhd', xml_state, 'root_dir', 'target_dir')
mock_vhd.assert_called_once_with(
xml_state, 'root_dir', 'target_dir'
)
@patch('kiwi.storage.subformat.DiskFormatVhdFixed')
def test_disk_format_vhdfixed(self, mock_vhdfixed):
xml_state = mock.Mock()
xml_state.build_type.get_vhdfixedtag = mock.Mock(
return_value='disk-tag'
)
DiskFormat('vhdfixed', xml_state, 'root_dir', 'target_dir')
mock_vhdfixed.assert_called_once_with(
xml_state, 'root_dir', 'target_dir', {'--tag': 'disk-tag'}
)
@patch('kiwi.storage.subformat.DiskFormatGce')
def test_disk_format_gce(self, mock_gce):
xml_state = mock.Mock()
xml_state.build_type.get_gcelicense = mock.Mock(
return_value='gce_license_tag'
)
DiskFormat('gce', xml_state, 'root_dir', 'target_dir')
mock_gce.assert_called_once_with(
xml_state, 'root_dir', 'target_dir', {'--tag': 'gce_license_tag'}
)
@patch('kiwi.storage.subformat.DiskFormatVmdk')
def test_disk_format_vmdk(self, mock_vmdk):
xml_state = mock.Mock()
vmdisk = mock.Mock()
vmdisk.get_controller = mock.Mock(
return_value='controller'
)
vmdisk.get_diskmode = mock.Mock(
return_value='disk-mode'
)
xml_state.get_build_type_vmdisk_section = mock.Mock(
return_value=vmdisk
)
DiskFormat('vmdk', xml_state, 'root_dir', 'target_dir')
mock_vmdk.assert_called_once_with(
xml_state, 'root_dir', 'target_dir',
{'adapter_type=controller': None, 'subformat=disk-mode': None}
)