kiwi-el8/test/unit/system_root_import_test.py
David Cassany 8f1048f840
Refactor OCI images packing
This commit refactors the OCI images support:

  * added import_container_image and export_container_image methods
    to oci_tools classes. 'umoci' and 'buildah' consume different
    formats thus the inital skopeo call to import a container is tool
    dependent.

  * use oci-archive transport for packing the OCI images, this causes
    docker and oci operations to just diverge on transport type.

  * add_tag method no longer needed in oci_tools/base, skopeo is used
    for that matter.

  * container/docker.py class is no longer needed. The difference
    between docker and OCI images is just on packing format which is just
    a parameter in skopeo. It does not deserve a dedicated class

  * system/root_import/docker.py class no longer needed. The difference
    between OCI and Docker class was just the transport type for the
    skopeo call. It does not deserve a dedicated class
2019-03-11 13:54:42 +01:00

29 lines
999 B
Python

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