File: init_test.py

package info (click to toggle)
kiwi 10.2.42-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,592 kB
  • sloc: python: 69,712; sh: 4,230; xml: 3,386; ansic: 391; makefile: 360
file content (39 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from unittest.mock import (
    Mock, patch
)
from pytest import raises

from kiwi.exceptions import KiwiBootImageSetupError
from kiwi.boot.image import BootImage


class TestBootImage:
    def setup(self):
        self.xml_state = Mock()
        self.xml_state.get_initrd_system = Mock(
            return_value='kiwi'
        )

    def setup_method(self, cls):
        self.setup()

    def test_boot_image_not_implemented(self):
        self.xml_state.get_initrd_system.return_value = 'foo'
        with raises(KiwiBootImageSetupError):
            BootImage.new(self.xml_state, 'target_dir')

    @patch('kiwi.boot.image.builtin_kiwi.BootImageKiwi')
    def test_boot_image_task_kiwi(self, mock_kiwi):
        self.xml_state.get_initrd_system.return_value = 'kiwi'
        BootImage.new(self.xml_state, 'target_dir')
        mock_kiwi.assert_called_once_with(
            self.xml_state, 'target_dir', None, None
        )

    @patch('kiwi.boot.image.dracut.BootImageDracut')
    def test_boot_image_task_dracut(self, mock_dracut):
        self.xml_state.get_initrd_system.return_value = 'dracut'
        BootImage.new(self.xml_state, 'target_dir', 'root_dir')
        mock_dracut.assert_called_once_with(
            self.xml_state, 'target_dir', 'root_dir', None
        )