# 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
    'mac': '52:54:00:12:35:02', 'pci_slot': 3, 'vf_index': '89',
    'pf_device': 'net_enp0s3_52_54_00_12_35_02', 'src_vlans': '20'}

FAKE_TAP_SERVICE = {'port': {
    'id': 'fake_1', 'mac_address': "52:54:00:12:35:02",
    'binding:profile': {'pci_slot': 3},
    'binding:vif_details': {'vlan': '20'}}}

FAKE_TAP_FLOW = {'port': FAKE_TAP_SERVICE['port'],
                 'ts_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'}}


class TestSriovNicTaas(base.TaasTestCase):
    def setUp(self):
        super(TestSriovNicTaas, self).setUp()

    @mock.patch.object(sriov_nic_taas, 'sriov_utils')
    def test_create_tap_service(self, mock_sriov_utils):
        tap_service = FAKE_TAP_SERVICE
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            return_value = FAKE_PORT_PARAMS
        obj = sriov_nic_taas.SriovNicTaasDriver()
        obj.initialize()
        obj.create_tap_service(tap_service)
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            assert_called_once_with(tap_service['port'])


# 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

    'mac': '52:54:00:12:35:02', 'pci_slot': 3, 'vf_index': '89',
    'pf_device': 'net_enp0s3_52_54_00_12_35_02', 'src_vlans': '20'}

FAKE_TAP_SERVICE = {'port': {
    'id': 'fake_1', 'mac_address': "52:54:00:12:35:02",
    'binding:profile': {'pci_slot': 3},
    'binding:vif_details': {'vlan': '20'}}}

FAKE_TAP_FLOW = {'port': FAKE_TAP_SERVICE['port'],
                 'ts_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'}}


class TestSriovNicTaas(base.TaasTestCase):
    def setUp(self):
        super(TestSriovNicTaas, self).setUp()

    @mock.patch.object(sriov_nic_taas, 'sriov_utils')
    def test_create_tap_service(self, mock_sriov_utils):
        tap_service = FAKE_TAP_SERVICE
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            return_value = FAKE_PORT_PARAMS
        obj = sriov_nic_taas.SriovNicTaasDriver()
        obj.initialize()
        obj.create_tap_service(tap_service)
        mock_sriov_utils.SriovNicUtils().get_sriov_port_params.\
            assert_called_once_with(tap_service['port'])


    @mock.patch.object(sriov_nic_taas, 'sriov_utils')