# Path: neutron_vpnaas/services/vpn/common/netns_wrapper.py
# LOG = logging.getLogger(__name__)
# def setup_conf():
# def execute(cmd):
# def filter_command(command, rootwrap_config):
# def execute_with_mount():
# def main():


from unittest import mock
from neutron.tests import base
from neutron_vpnaas.services.vpn.common import netns_wrapper as nswrap
        self.isdir.return_value = True
        self.samefile.return_value = False

    def patch_obj(self, obj, method):
        _m = mock.patch.object(obj, method)
        _mock = _m.start()
        setattr(self, method, _mock)

    def patch_cls(self, patch_class):
        _m = mock.patch(patch_class)
        mock_name = patch_class.split('.')[-1]
        _mock = _m.start()
        setattr(self, mock_name, _mock)

    def test_netns_wrap_fail_without_netns(self):
        self.samefile.return_value = True
        return_val = nswrap.execute_with_mount()
        self.assertTrue(return_val)

    def test_netns_wrap(self):
        self.conf.cmd = 'ls,-al'
        return_val = nswrap.execute_with_mount()
        exp_calls = [mock.call(['mount', '--bind', '/dir/foo', '/foo']),
                     mock.call(['mount', '--bind', '/dir/var', '/var']),
                     mock.call('ls,-al')]
        self.execute.assert_has_calls(exp_calls, any_order=True)
        self.assertFalse(return_val)

    def test_netns_wrap_fail_without_cmd(self):
        self.conf.cmd = None

# Path: neutron_vpnaas/services/vpn/common/netns_wrapper.py
# LOG = logging.getLogger(__name__)
# def setup_conf():
# def execute(cmd):
# def filter_command(command, rootwrap_config):
# def execute_with_mount():
# def main():


# Path: neutron_vpnaas/tests/unit/services/vpn/common/test_netns_wrapper.py
from unittest import mock
from neutron.tests import base
from neutron_vpnaas.services.vpn.common import netns_wrapper as nswrap

        self.isdir.return_value = True
        self.samefile.return_value = False

    def patch_obj(self, obj, method):
        _m = mock.patch.object(obj, method)
        _mock = _m.start()
        setattr(self, method, _mock)

    def patch_cls(self, patch_class):
        _m = mock.patch(patch_class)
        mock_name = patch_class.split('.')[-1]
        _mock = _m.start()
        setattr(self, mock_name, _mock)

    def test_netns_wrap_fail_without_netns(self):
        self.samefile.return_value = True
        return_val = nswrap.execute_with_mount()
        self.assertTrue(return_val)

    def test_netns_wrap(self):
        self.conf.cmd = 'ls,-al'
        return_val = nswrap.execute_with_mount()
        exp_calls = [mock.call(['mount', '--bind', '/dir/foo', '/foo']),
                     mock.call(['mount', '--bind', '/dir/var', '/var']),
                     mock.call('ls,-al')]
        self.execute.assert_has_calls(exp_calls, any_order=True)
        self.assertFalse(return_val)

    def test_netns_wrap_fail_without_cmd(self):
        self.conf.cmd = None

        return_val = nswrap.execute_with_mount()