kiwi-el8/test/unit/system_root_init_test.py
Marcus Schäfer d1e689e00b
Create VMware settings file for vmdk subformat
In order to run or convert the vmdk with VMware products a
settings file is required.
2016-05-11 18:46:02 +02:00

49 lines
1.3 KiB
Python

from mock import patch
import mock
from .test_helper import *
from kiwi.exceptions import (
KiwiRootDirExists,
KiwiRootInitCreationError
)
from kiwi.system.root_init import RootInit
class TestRootInit(object):
@raises(KiwiRootDirExists)
@patch('os.path.exists')
def test_init_raises_error(self, mock_path):
mock_path.return_value = True
RootInit('root_dir')
@raises(KiwiRootInitCreationError)
@patch('kiwi.command.Command.run')
@patch('os.path.exists')
def test_create_raises_error(self, mock_path, mock_command):
mock_path.return_value = False
mock_command.side_effect = KiwiRootInitCreationError('some-error')
root = RootInit('root_dir')
root.create()
@patch('kiwi.command.Command.run')
@patch('os.path.exists')
def test_create(self, mock_path, mock_command):
mock_path.return_value = False
root = RootInit('root_dir')
mock_path.return_value = True
root.create()
assert mock_command.called
@patch('kiwi.command.Command.run')
@patch('os.path.exists')
def test_delete(self, mock_path, mock_command):
mock_path.return_value = False
root = RootInit('root_dir')
root.delete()
mock_command.assert_called_once_with(
['rm', '-r', '-f', 'root_dir']
)