kiwi-el8/test/unit/container_image_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

28 lines
840 B
Python

from mock import patch
from .test_helper import raises
from kiwi.exceptions import KiwiContainerImageSetupError
from kiwi.container import ContainerImage
class TestContainerImage(object):
@raises(KiwiContainerImageSetupError)
def test_container_image_not_implemented(self):
ContainerImage('foo', 'root_dir')
@patch('kiwi.container.ContainerImageOCI')
def test_container_image_docker(self, mock_docker):
ContainerImage('docker', 'root_dir')
mock_docker.assert_called_once_with(
'root_dir', 'docker-archive', custom_args=None
)
@patch('kiwi.container.ContainerImageOCI')
def test_container_image_oci(self, mock_oci):
ContainerImage('oci', 'root_dir')
mock_oci.assert_called_once_with(
'root_dir', 'oci-archive', custom_args=None
)