# Path: neutron_taas/common/utils.py
# def get_list_from_ranges_str(ranges_str):
# def get_ranges_str_from_list(ranges):
# 
# 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_utils.py
# LOG = logging.getLogger(__name__)
#         VIRTFN_RE = re.compile(r"virtfn(\d+)")
# class SriovNicUtils(object):
#     def __init__(self):
#     def execute_sysfs_command(self, command, ts_port_params,
#                               src_port_params,
#                               common_vlans_ranges_str,
#                               vf_to_vf_all_vlans, direction):
#     def _get_sysfs_netdev_path(self, pci_addr, pf_interface):
#     def get_ifname_by_pci_address(self, pci_addr, pf_interface=False):
#     def get_mac_by_pci_address(self, pci_addr, pf_interface=False):
#     def get_vf_num_by_pci_address(self, pci_addr):
#     def get_net_name_by_vf_pci_address(self, vfaddress, pf_interface=False):
#     def get_sriov_port_params(self, sriov_port):
# 
# Path: neutron_taas/tests/base.py
# class TaasTestCase(base.BaseTestCase):


import copy
import re
from unittest import mock
from neutron_taas.common import utils as common_utils
from neutron_taas.services.taas.drivers.linux import sriov_nic_exceptions \
    as taas_exc
from neutron_taas.services.taas.drivers.linux import sriov_nic_utils
from neutron_taas.tests import base
            get_vf_num_by_pci_address(12))

    @mock.patch.object(sriov_nic_utils, 'glob')
    @mock.patch.object(sriov_nic_utils, 're')
    @mock.patch.object(sriov_nic_utils, 'os')
    @mock.patch.object(sriov_nic_utils, 'open', create=True)
    @mock.patch.object(sriov_nic_utils, 'portbindings')
    def test_get_sriov_port_params(self, mock_port_bindings, mock_open,
                                   mock_os, mock_re, mock_glob):
        sriov_port = copy.deepcopy(FAKE_SRIOV_PORT)
        fake_profile = mock_port_bindings.PROFILE = 'binding:profile'
        mock_port_bindings.VIF_DETAILS = 'binding:vif_details'
        sriov_port[fake_profile]['pci_slot'] = 3
        mock_glob.iglob.return_value = ['file1']
        mock_os.readlink.return_value = 12
        mock_re.compile().search.return_value = re.match(r"(\d+)", "89")
        mock_os.listdir.return_value = ['net_enp0s2_52_54_00_12_35_02',
                                        'net_enp0s3_52_54_00_12_35_02']
        mock_os.path.join.return_value = 'random'
        fake_file_handle = ["52:54:00:12:35:02"]
        fake_file_iter = fake_file_handle.__iter__()
        mock_open.return_value.__enter__.return_value = fake_file_iter
        expected_output = {
            '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}
        self.assertEqual(
            expected_output, sriov_nic_utils.SriovNicUtils().
            get_sriov_port_params(sriov_port))

    @mock.patch.object(sriov_nic_utils, 'glob')

# Path: neutron_taas/common/utils.py
# def get_list_from_ranges_str(ranges_str):
# def get_ranges_str_from_list(ranges):
# 
# 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_utils.py
# LOG = logging.getLogger(__name__)
#         VIRTFN_RE = re.compile(r"virtfn(\d+)")
# class SriovNicUtils(object):
#     def __init__(self):
#     def execute_sysfs_command(self, command, ts_port_params,
#                               src_port_params,
#                               common_vlans_ranges_str,
#                               vf_to_vf_all_vlans, direction):
#     def _get_sysfs_netdev_path(self, pci_addr, pf_interface):
#     def get_ifname_by_pci_address(self, pci_addr, pf_interface=False):
#     def get_mac_by_pci_address(self, pci_addr, pf_interface=False):
#     def get_vf_num_by_pci_address(self, pci_addr):
#     def get_net_name_by_vf_pci_address(self, vfaddress, pf_interface=False):
#     def get_sriov_port_params(self, sriov_port):
# 
# Path: neutron_taas/tests/base.py
# class TaasTestCase(base.BaseTestCase):


# Path: neutron_taas/tests/unit/services/drivers/test_linux_sriov_utils.py
import copy
import re
from unittest import mock
from neutron_taas.common import utils as common_utils
from neutron_taas.services.taas.drivers.linux import sriov_nic_exceptions \
    as taas_exc
from neutron_taas.services.taas.drivers.linux import sriov_nic_utils
from neutron_taas.tests import base

            get_vf_num_by_pci_address(12))

    @mock.patch.object(sriov_nic_utils, 'glob')
    @mock.patch.object(sriov_nic_utils, 're')
    @mock.patch.object(sriov_nic_utils, 'os')
    @mock.patch.object(sriov_nic_utils, 'open', create=True)
    @mock.patch.object(sriov_nic_utils, 'portbindings')
    def test_get_sriov_port_params(self, mock_port_bindings, mock_open,
                                   mock_os, mock_re, mock_glob):
        sriov_port = copy.deepcopy(FAKE_SRIOV_PORT)
        fake_profile = mock_port_bindings.PROFILE = 'binding:profile'
        mock_port_bindings.VIF_DETAILS = 'binding:vif_details'
        sriov_port[fake_profile]['pci_slot'] = 3
        mock_glob.iglob.return_value = ['file1']
        mock_os.readlink.return_value = 12
        mock_re.compile().search.return_value = re.match(r"(\d+)", "89")
        mock_os.listdir.return_value = ['net_enp0s2_52_54_00_12_35_02',
                                        'net_enp0s3_52_54_00_12_35_02']
        mock_os.path.join.return_value = 'random'
        fake_file_handle = ["52:54:00:12:35:02"]
        fake_file_iter = fake_file_handle.__iter__()
        mock_open.return_value.__enter__.return_value = fake_file_iter
        expected_output = {
            '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}
        self.assertEqual(
            expected_output, sriov_nic_utils.SriovNicUtils().
            get_sriov_port_params(sriov_port))

    @mock.patch.object(sriov_nic_utils, 'glob')

    @mock.patch.object(sriov_nic_utils, 're')