File: oci_test.py

package info (click to toggle)
kiwi 10.2.45-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,616 kB
  • sloc: python: 70,131; sh: 4,309; xml: 3,389; ansic: 391; makefile: 360
file content (39 lines) | stat: -rw-r--r-- 1,341 bytes parent folder | download | duplicates (2)
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 patch
from unittest.mock import call
import unittest.mock as mock

from kiwi.container.setup.oci import ContainerSetupOCI


class TestContainerSetupOCI:
    @patch('os.path.exists')
    def setup(self, mock_exists):
        mock_exists.return_value = True

        self.container = ContainerSetupOCI(
            'root_dir', {'container_name': 'system'}
        )

        self.container.deactivate_bootloader_setup = mock.Mock()
        self.container.deactivate_root_filesystem_check = mock.Mock()
        self.container.setup_root_console = mock.Mock()
        self.container.deactivate_systemd_service = mock.Mock()

    @patch('os.path.exists')
    def setup_method(self, cls, mock_exists):
        self.setup()

    def test_setup(self):
        self.container.setup()
        self.container.deactivate_bootloader_setup.assert_called_once_with()
        self.container.deactivate_root_filesystem_check.assert_called_once_with()
        assert self.container.deactivate_systemd_service.call_args_list == [
            call('device-mapper.service'),
            call('kbd.service'),
            call('swap.service'),
            call('udev.service'),
            call('proc-sys-fs-binfmt_misc.automount')
        ]

    def test_post_init(self):
        self.container.custom_args['container_name'] == 'system'