def test_create_derived_checksum_match_failed( self, mock_exists, mock_image, mock_checksum ): def side_effect(filename): if filename.endswith('.config/kiwi/config.yml'): return False elif filename.endswith('etc/kiwi.yml'): return False else: return True mock_exists.side_effect = side_effect container = ContainerBuilder( self.xml_state, 'target_dir', 'root_dir' ) container.result = mock.Mock() checksum = mock.Mock() checksum.matches = mock.Mock( return_value=False ) mock_checksum.return_value = checksum with raises(KiwiContainerBuilderError): container.create()
def test_create_keep_tmpdirs(self, mock_exists, mock_image, mock_checksum): def side_effect(filename): if filename.endswith('.config/kiwi/config.yml'): return False elif filename.endswith('etc/kiwi.yml'): return False else: return True mock_exists.side_effect = side_effect container_image = mock.Mock() container_image.create = mock.Mock( return_value='target_dir/image_name.x86_64-1.2.3.docker.tar') mock_image.new.return_value = container_image self.xml_state.build_type.get_ensure_empty_tmpdirs = mock.Mock( return_value=False) container = ContainerBuilder(self.xml_state, 'target_dir', 'root_dir') container.result = mock.Mock() container.create() container_image.create.assert_called_once_with( 'target_dir/image_name.x86_64-1.2.3.docker.tar', 'root_dir/image/imported_root', False)
def test_create_derived(self, mock_exists, mock_image, mock_checksum): def side_effect(filename): if filename.endswith('.config/kiwi/config.yml'): return False elif filename.endswith('etc/kiwi.yml'): return False else: return True mock_exists.side_effect = side_effect container_image = mock.Mock() container_image.create = mock.Mock( return_value='target_dir/image_name.x86_64-1.2.3.docker.tar.xz') mock_image.return_value = container_image container = ContainerBuilder(self.xml_state, 'target_dir', 'root_dir') container.result = mock.Mock() checksum = mock.Mock() checksum.md5 = mock.Mock(return_value='checksumvalue') mock_checksum.return_value = checksum self.setup.export_package_verification.return_value = '.verified' self.setup.export_package_list.return_value = '.packages' container.create() mock_checksum.assert_called_once_with('root_dir/image/imported_root') checksum.matches.assert_called_once_with( 'checksumvalue', 'root_dir/image/imported_root.md5') mock_image.assert_called_once_with('docker', 'root_dir', self.container_config) container_image.create.assert_called_once_with( 'target_dir/image_name.x86_64-1.2.3.docker.tar', 'root_dir/image/imported_root') assert container.result.add.call_args_list == [ call(key='container', filename='target_dir/image_name.x86_64-1.2.3.docker.tar.xz', use_for_bundle=True, compress=False, shasum=True), call(key='image_packages', filename='.packages', use_for_bundle=True, compress=False, shasum=False), call(key='image_verified', filename='.verified', use_for_bundle=True, compress=False, shasum=False) ] self.setup.export_package_verification.assert_called_once_with( 'target_dir') self.setup.export_package_list.assert_called_once_with('target_dir')
def test_create_derived_checksum_match_failed(self, mock_exists, mock_image, mock_checksum): mock_exists.return_value = True container = ContainerBuilder(self.xml_state, 'target_dir', 'root_dir') container.result = mock.Mock() checksum = mock.Mock() checksum.matches = mock.Mock(return_value=False) mock_checksum.return_value = checksum container.create()
def test_create_derived_checksum_match_failed( self, mock_exists, mock_image, mock_checksum ): def side_effect(filename): if filename.endswith('.config/kiwi/config.yml'): return False else: return True mock_exists.side_effect = side_effect container = ContainerBuilder( self.xml_state, 'target_dir', 'root_dir' ) container.result = mock.Mock() checksum = mock.Mock() checksum.matches = mock.Mock( return_value=False ) mock_checksum.return_value = checksum container.create()
def test_create_derived(self, mock_exists, mock_image, mock_checksum): def side_effect(filename): if filename.endswith('.config/kiwi/config.yml'): return False else: return True mock_exists.side_effect = side_effect container_image = mock.Mock() container_image.create = mock.Mock( return_value='target_dir/image_name.x86_64-1.2.3.docker.tar.xz' ) mock_image.return_value = container_image container = ContainerBuilder( self.xml_state, 'target_dir', 'root_dir' ) container.result = mock.Mock() checksum = mock.Mock() checksum.md5 = mock.Mock( return_value='checksumvalue' ) mock_checksum.return_value = checksum self.setup.export_package_verification.return_value = '.verified' self.setup.export_package_list.return_value = '.packages' container.create() mock_checksum.assert_called_once_with('root_dir/image/imported_root') checksum.matches.assert_called_once_with( 'checksumvalue', 'root_dir/image/imported_root.md5' ) mock_image.assert_called_once_with( 'docker', 'root_dir', self.container_config ) container_image.create.assert_called_once_with( 'target_dir/image_name.x86_64-1.2.3.docker.tar', 'root_dir/image/imported_root' ) assert container.result.add.call_args_list == [ call( key='container', filename='target_dir/image_name.x86_64-1.2.3.docker.tar.xz', use_for_bundle=True, compress=False, shasum=True ), call( key='image_packages', filename='.packages', use_for_bundle=True, compress=False, shasum=False ), call( key='image_verified', filename='.verified', use_for_bundle=True, compress=False, shasum=False ) ] self.setup.export_package_verification.assert_called_once_with( 'target_dir' ) self.setup.export_package_list.assert_called_once_with( 'target_dir' )