# Path: f5lbaasdriver/v2/bigip/exceptions.py
# class F5LBaaSv2DriverException(q_exc.NeutronException):
# class F5MismatchedTenants(F5LBaaSv2DriverException):
# class F5DeleteListenerWithAttachedPool(F5LBaaSv2DriverException):
# class PolicyHasMoreThanOneListener(F5LBaaSv2DriverException):
# class RuleHasMoreThanOnePolicy(F5LBaaSv2DriverException):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __str__(self):


import mock
import pytest
import f5lbaasdriver.v2.bigip.driver_v2 as dv2
from f5lbaasdriver.v2.bigip import exceptions as f5_exc
from neutron_lbaas.db.loadbalancer import models
from neutron_lbaas.extensions import lbaas_agentschedulerv2
    l7rule_mgr.delete(mock_ctx, fake_l7rule)
    assert mock_driver.agent_rpc.delete_l7rule.call_args == \
        mock.call(mock_ctx, fake_l7rule.to_dict(), {}, 'test_agent')


@mock.patch('f5lbaasdriver.v2.bigip.driver_v2.LOG')
def test_mgr__call_rpc_no_eligible_agent_exception(
        mock_log, happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    pol_mgr = dv2.L7PolicyManager(mock_driver)
    pol_mgr._setup_crud = mock.MagicMock(
        name='mock_setup_crud',
        side_effect=lbaas_agentschedulerv2.NoEligibleLbaasAgent(
            loadbalancer_id='test_lb')
    )
    fake_pol = FakePolicy(id='test_lb')
    pol_mgr.delete(mock_ctx, fake_pol)
    assert mock_log.error.call_args == mock.call(
        'Exception: delete_l7policy: No eligible agent found for '
        'loadbalancer test_lb.'
    )
    assert mock_driver.plugin.db.update_status.call_args is None


@mock.patch('f5lbaasdriver.v2.bigip.driver_v2.LOG')
def test_mgr__call_rpc_mismatch_tenant_exception(
        mock_log, happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    rule_mgr = dv2.L7RuleManager(mock_driver)
    rule_mgr._setup_crud = mock.MagicMock(

# Path: f5lbaasdriver/v2/bigip/exceptions.py
# class F5LBaaSv2DriverException(q_exc.NeutronException):
# class F5MismatchedTenants(F5LBaaSv2DriverException):
# class F5DeleteListenerWithAttachedPool(F5LBaaSv2DriverException):
# class PolicyHasMoreThanOneListener(F5LBaaSv2DriverException):
# class RuleHasMoreThanOnePolicy(F5LBaaSv2DriverException):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __str__(self):


# Path: f5lbaasdriver/v2/bigip/test/test_driver_v2.py
import mock
import pytest
import f5lbaasdriver.v2.bigip.driver_v2 as dv2
from f5lbaasdriver.v2.bigip import exceptions as f5_exc
from neutron_lbaas.db.loadbalancer import models
from neutron_lbaas.extensions import lbaas_agentschedulerv2

    l7rule_mgr.delete(mock_ctx, fake_l7rule)
    assert mock_driver.agent_rpc.delete_l7rule.call_args == \
        mock.call(mock_ctx, fake_l7rule.to_dict(), {}, 'test_agent')


@mock.patch('f5lbaasdriver.v2.bigip.driver_v2.LOG')
def test_mgr__call_rpc_no_eligible_agent_exception(
        mock_log, happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    pol_mgr = dv2.L7PolicyManager(mock_driver)
    pol_mgr._setup_crud = mock.MagicMock(
        name='mock_setup_crud',
        side_effect=lbaas_agentschedulerv2.NoEligibleLbaasAgent(
            loadbalancer_id='test_lb')
    )
    fake_pol = FakePolicy(id='test_lb')
    pol_mgr.delete(mock_ctx, fake_pol)
    assert mock_log.error.call_args == mock.call(
        'Exception: delete_l7policy: No eligible agent found for '
        'loadbalancer test_lb.'
    )
    assert mock_driver.plugin.db.update_status.call_args is None


@mock.patch('f5lbaasdriver.v2.bigip.driver_v2.LOG')
def test_mgr__call_rpc_mismatch_tenant_exception(
        mock_log, happy_path_driver):
    mock_driver, mock_ctx = happy_path_driver
    rule_mgr = dv2.L7RuleManager(mock_driver)
    rule_mgr._setup_crud = mock.MagicMock(

        name='mock_setup_crud', side_effect=f5_exc.F5MismatchedTenants