# Path: neutron_taas/services/taas/drivers/linux/sriov_nic_exceptions.py
# class SriovNicSwitchDriverInvocationError(qexception.Invalid):
# class PciDeviceNotFoundById(qexception.NotFound):
# class PciSlotNotFound(qexception.NotFound):
# 
# Path: neutron_taas/services/taas/drivers/linux/sriov_nic_taas.py
# LOG = logging.getLogger(__name__)
# class SriovNicTaasDriver(taas_base.TaasAgentDriver):
#     def __init__(self):
#     def initialize(self):
#     def consume_api(self, agent_api):
#     def create_tap_service(self, tap_service):
#     def delete_tap_service(self, tap_service):
#     def create_tap_flow(self, tap_flow):
#     def delete_tap_flow(self, tap_flow):
# 
# Path: neutron_taas/tests/base.py
# class TaasTestCase(base.BaseTestCase):


import copy
from unittest import mock
from neutron_taas.services.taas.drivers.linux import sriov_nic_exceptions \
    as taas_exc
from neutron_taas.services.taas.drivers.linux import sriov_nic_taas
from neutron_taas.tests import base
    @mock.patch.object(sriov_nic_taas, 'sriov_utils')
    def test_delete_tap_flow(self, mock_sriov_utils):
        tap_flow = {'port': FAKE_TAP_SERVICE['port'],
                    'tap_service_port': FAKE_TAP_SERVICE['port'],
                    'source_vlans_list': ['4-6', '8-10', '15-18,20'],
                    'vlan_filter_list': ['1-5,9,18,20,27-30,4000-4095'],
                    'tap_flow': {'direction': 'IN', 'vlan_filter': '20'}}
        src_port_params = ts_port_params = copy.deepcopy(FAKE_PORT_PARAMS)
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            side_effect = [src_port_params, ts_port_params]
        obj = sriov_nic_taas.SriovNicTaasDriver()
        obj.initialize()
        self.assertIsNone(obj.delete_tap_flow(tap_flow))
        self.assertEqual(2, mock_sriov_utils.SriovNicUtils().
                         execute_sysfs_command.call_count)

    @mock.patch.object(sriov_nic_taas, 'sriov_utils')
    def test_delete_tap_flow_no_source_pci_slot(
            self, mock_sriov_utils):
        tap_flow = {'port': FAKE_TAP_SERVICE['port'],
                    'tap_service_port': FAKE_TAP_SERVICE['port'],
                    'source_vlans_list': [4, 5, 9],
                    'tap_flow': {'direction': 'IN', 'vlan_filter': 20}}
        src_port_params = copy.deepcopy(FAKE_PORT_PARAMS)
        ts_port_params = copy.deepcopy(FAKE_PORT_PARAMS)
        src_port_params['pci_slot'] = None
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            side_effect = [src_port_params, ts_port_params]
        obj = sriov_nic_taas.SriovNicTaasDriver()
        obj.initialize()

# Path: neutron_taas/services/taas/drivers/linux/sriov_nic_exceptions.py
# class SriovNicSwitchDriverInvocationError(qexception.Invalid):
# class PciDeviceNotFoundById(qexception.NotFound):
# class PciSlotNotFound(qexception.NotFound):
# 
# Path: neutron_taas/services/taas/drivers/linux/sriov_nic_taas.py
# LOG = logging.getLogger(__name__)
# class SriovNicTaasDriver(taas_base.TaasAgentDriver):
#     def __init__(self):
#     def initialize(self):
#     def consume_api(self, agent_api):
#     def create_tap_service(self, tap_service):
#     def delete_tap_service(self, tap_service):
#     def create_tap_flow(self, tap_flow):
#     def delete_tap_flow(self, tap_flow):
# 
# Path: neutron_taas/tests/base.py
# class TaasTestCase(base.BaseTestCase):


# Path: neutron_taas/tests/unit/services/drivers/test_linux_sriov_nic_driver.py
import copy
from unittest import mock
from neutron_taas.services.taas.drivers.linux import sriov_nic_exceptions \
    as taas_exc
from neutron_taas.services.taas.drivers.linux import sriov_nic_taas
from neutron_taas.tests import base

    @mock.patch.object(sriov_nic_taas, 'sriov_utils')
    def test_delete_tap_flow(self, mock_sriov_utils):
        tap_flow = {'port': FAKE_TAP_SERVICE['port'],
                    'tap_service_port': FAKE_TAP_SERVICE['port'],
                    'source_vlans_list': ['4-6', '8-10', '15-18,20'],
                    'vlan_filter_list': ['1-5,9,18,20,27-30,4000-4095'],
                    'tap_flow': {'direction': 'IN', 'vlan_filter': '20'}}
        src_port_params = ts_port_params = copy.deepcopy(FAKE_PORT_PARAMS)
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            side_effect = [src_port_params, ts_port_params]
        obj = sriov_nic_taas.SriovNicTaasDriver()
        obj.initialize()
        self.assertIsNone(obj.delete_tap_flow(tap_flow))
        self.assertEqual(2, mock_sriov_utils.SriovNicUtils().
                         execute_sysfs_command.call_count)

    @mock.patch.object(sriov_nic_taas, 'sriov_utils')
    def test_delete_tap_flow_no_source_pci_slot(
            self, mock_sriov_utils):
        tap_flow = {'port': FAKE_TAP_SERVICE['port'],
                    'tap_service_port': FAKE_TAP_SERVICE['port'],
                    'source_vlans_list': [4, 5, 9],
                    'tap_flow': {'direction': 'IN', 'vlan_filter': 20}}
        src_port_params = copy.deepcopy(FAKE_PORT_PARAMS)
        ts_port_params = copy.deepcopy(FAKE_PORT_PARAMS)
        src_port_params['pci_slot'] = None
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            side_effect = [src_port_params, ts_port_params]
        obj = sriov_nic_taas.SriovNicTaasDriver()
        obj.initialize()

        self.assertRaises(taas_exc.PciSlotNotFound, obj.delete_tap_flow,