kiwi-el8/test/unit/system/root_import/init_test.py
Alexandre Detiste fb69627ad3
Use unittest.mock from core python everywhere
mock was an independent module that has been merged into the Python standard library.
2024-02-18 22:15:30 +01:00

29 lines
1003 B
Python

from unittest.mock import patch
from pytest import raises
from kiwi.system.root_import import RootImport
from kiwi.exceptions import KiwiRootImportError
class TestRootImport:
@patch('kiwi.system.root_import.oci.RootImportOCI')
def test_docker_import(self, mock_docker_import):
RootImport.new('root_dir', 'file:///image.tar.xz', 'docker')
mock_docker_import.assert_called_once_with(
'root_dir', 'file:///image.tar.xz',
{'archive_transport': 'docker-archive'}
)
@patch('kiwi.system.root_import.oci.RootImportOCI')
def test_oci_import(self, mock_oci_import):
RootImport.new('root_dir', 'file:///image.tar.xz', 'oci')
mock_oci_import.assert_called_once_with(
'root_dir', 'file:///image.tar.xz',
{'archive_transport': 'oci-archive'}
)
def test_not_implemented_import(self):
with raises(KiwiRootImportError):
RootImport.new('root_dir', 'file:///image.tar.xz', 'foo')