# Path: os_brick/caches/opencas.py
# LOG = logging.getLogger(__name__)
# class OpenCASEngine(executor.Executor, caches.CacheEngineBase):
#     def __init__(self, **kwargs):
#     def os_execute(self, *cmd, **kwargs):
#     def is_engine_ready(self, **kwargs):
#     def attach_volume(self, **kwargs):
#     def detach_volume(self, **kwargs):
#     def _get_mapped_casdev(self, core):
#     def _get_mapped_coredev(self, casdev):
#     def _map_casdisk(self, core):
#     def _unmap_casdisk(self, coreid):
# 
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, *args, **kwargs):
#     def __repr__(self):
#     def __nonzero__(self) -> bool:
#     def add_exception(self, exc_type, exc_val, exc_tb) -> None:
#     def context(self,
#                 catch_exception: bool,
#                 msg: str = '',
#                 *msg_args: Iterable):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# 
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
#     SENTINEL = object()
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
#     def patch(self, path, *args, **kwargs):


from unittest import mock
from oslo_concurrency import processutils as putils
from os_brick.caches import opencas
from os_brick import exception
from os_brick.tests import base
    @mock.patch('os_brick.caches.opencas.OpenCASEngine._get_mapped_casdev')
    def test_map_casdisk(self, moc_get_mapped_casdev, moc_exec):
        engine = opencas.OpenCASEngine(root_helper=None, opencas_cache_id=1)

        moc_get_mapped_casdev.return_value = ''
        moc_exec.return_value = ('', '')
        engine._map_casdisk('/dev/sdd')
        moc_exec.assert_has_calls([
            mock.call('casadm', '-A', '-i', 1, '-d', '/dev/sdd',
                      run_as_root=True, root_helper=None)
        ])

    @mock.patch('os_brick.executor.Executor._execute')
    def test_unmap_casdisk(self, moc_exec):
        engine = opencas.OpenCASEngine(root_helper=None, opencas_cache_id=1)

        moc_exec.return_value = ('', '')
        engine._unmap_casdisk('1')

        moc_exec.assert_has_calls([
            mock.call('casadm', '-R', '-f', '-i', 1, '-j', '1',
                      run_as_root=True, root_helper=None)
        ])

    @mock.patch('os_brick.caches.opencas.OpenCASEngine._map_casdisk')
    def test_attach_volume(self, moc_map):
        engine = opencas.OpenCASEngine(root_helper=None, opencas_cache_id=1)
        moc_map.return_value = ''

        args = {'no_dev_path': 'path'}

# Path: os_brick/caches/opencas.py
# LOG = logging.getLogger(__name__)
# class OpenCASEngine(executor.Executor, caches.CacheEngineBase):
#     def __init__(self, **kwargs):
#     def os_execute(self, *cmd, **kwargs):
#     def is_engine_ready(self, **kwargs):
#     def attach_volume(self, **kwargs):
#     def detach_volume(self, **kwargs):
#     def _get_mapped_casdev(self, core):
#     def _get_mapped_coredev(self, casdev):
#     def _map_casdisk(self, core):
#     def _unmap_casdisk(self, coreid):
# 
# Path: os_brick/exception.py
# LOG = logging.getLogger(__name__)
# class BrickException(Exception):
# class NotFound(BrickException):
# class Invalid(BrickException):
# class InvalidParameterValue(Invalid):
# class NoFibreChannelHostsFound(BrickException):
# class NoFibreChannelVolumeDeviceFound(BrickException):
# class VolumeNotDeactivated(BrickException):
# class VolumeDeviceNotFound(BrickException):
# class VolumePathsNotFound(BrickException):
# class VolumePathNotRemoved(BrickException):
# class ProtocolNotSupported(BrickException):
# class TargetPortalNotFound(BrickException):
# class TargetPortalsNotFound(TargetPortalNotFound):
# class FailedISCSITargetPortalLogin(BrickException):
# class BlockDeviceReadOnly(BrickException):
# class VolumeGroupNotFound(BrickException):
# class VolumeGroupCreationFailed(BrickException):
# class CommandExecutionFailed(BrickException):
# class VolumeDriverException(BrickException):
# class InvalidIOHandleObject(BrickException):
# class VolumeEncryptionNotSupported(Invalid):
# class VolumeLocalCacheNotSupported(Invalid):
# class InvalidConnectorProtocol(ValueError):
# class ExceptionChainer(BrickException):
# class ExecutionTimeout(putils.ProcessExecutionError):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, *args, **kwargs):
#     def __repr__(self):
#     def __nonzero__(self) -> bool:
#     def add_exception(self, exc_type, exc_val, exc_tb) -> None:
#     def context(self,
#                 catch_exception: bool,
#                 msg: str = '',
#                 *msg_args: Iterable):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
# 
# Path: os_brick/tests/base.py
# class TestCase(testtools.TestCase):
#     SENTINEL = object()
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=SENTINEL, **kwargs):
#     def patch(self, path, *args, **kwargs):


# Path: os_brick/tests/caches/test_opencas.py
from unittest import mock
from oslo_concurrency import processutils as putils
from os_brick.caches import opencas
from os_brick import exception
from os_brick.tests import base

    @mock.patch('os_brick.caches.opencas.OpenCASEngine._get_mapped_casdev')
    def test_map_casdisk(self, moc_get_mapped_casdev, moc_exec):
        engine = opencas.OpenCASEngine(root_helper=None, opencas_cache_id=1)

        moc_get_mapped_casdev.return_value = ''
        moc_exec.return_value = ('', '')
        engine._map_casdisk('/dev/sdd')
        moc_exec.assert_has_calls([
            mock.call('casadm', '-A', '-i', 1, '-d', '/dev/sdd',
                      run_as_root=True, root_helper=None)
        ])

    @mock.patch('os_brick.executor.Executor._execute')
    def test_unmap_casdisk(self, moc_exec):
        engine = opencas.OpenCASEngine(root_helper=None, opencas_cache_id=1)

        moc_exec.return_value = ('', '')
        engine._unmap_casdisk('1')

        moc_exec.assert_has_calls([
            mock.call('casadm', '-R', '-f', '-i', 1, '-j', '1',
                      run_as_root=True, root_helper=None)
        ])

    @mock.patch('os_brick.caches.opencas.OpenCASEngine._map_casdisk')
    def test_attach_volume(self, moc_map):
        engine = opencas.OpenCASEngine(root_helper=None, opencas_cache_id=1)
        moc_map.return_value = ''

        args = {'no_dev_path': 'path'}

        self.assertRaises(exception.VolumePathsNotFound,