# Path: os_win/exceptions.py
#     class WindowsError(Exception):
#     class x_wmi(Exception):
#     class x_wmi_timed_out(x_wmi):
# class OSWinException(Exception):
# class NotFound(OSWinException):
# class PciDeviceNotFound(NotFound):
# class HyperVException(OSWinException):
# class VHDResizeException(HyperVException):
# class HyperVAuthorizationException(HyperVException):
# class HyperVVMNotFoundException(NotFound, HyperVException):
# class HyperVPortNotFoundException(NotFound, HyperVException):
# class HyperVvNicNotFound(NotFound, HyperVException):
# class HyperVvSwitchNotFound(NotFound, HyperVException):
# class Invalid(OSWinException):
# class UnsupportedOperation(Invalid):
# class InvalidParameterValue(Invalid):
# class InvalidVMVersion(Invalid):
# class SMBException(OSWinException):
# class Win32Exception(OSWinException):
# class VHDException(OSWinException):
# class VHDWin32APIException(VHDException, Win32Exception):
# class FCException(OSWinException):
# class FCWin32Exception(FCException, Win32Exception):
# class WMIException(OSWinException):
# class WqlException(OSWinException):
# class ISCSITargetException(OSWinException):
# class ISCSITargetWMIException(ISCSITargetException, WMIException):
# class ISCSIInitiatorAPIException(Win32Exception):
# class ISCSILunNotAvailable(ISCSITargetException):
# class Win32IOException(Win32Exception):
# class DiskNotFound(NotFound):
# class HyperVRemoteFXException(HyperVException):
# class HyperVClusterException(HyperVException):
# class DNSException(OSWinException):
# class Timeout(OSWinException):
# class DNSZoneNotFound(NotFound, DNSException):
# class DNSZoneAlreadyExists(DNSException):
# class WMIJobFailed(HyperVException):
# class JobTerminateFailed(HyperVException):
# class ClusterException(OSWinException):
# class ClusterObjectNotFound(NotFound, ClusterException):
# class ClusterWin32Exception(ClusterException, Win32Exception):
# class ClusterGroupMigrationFailed(ClusterException):
# class ClusterGroupMigrationTimeOut(ClusterGroupMigrationFailed):
# class ClusterPropertyRetrieveFailed(ClusterException):
# class ClusterPropertyListEntryNotFound(ClusterPropertyRetrieveFailed):
# class ClusterPropertyListParsingError(ClusterPropertyRetrieveFailed):
# class SCSIPageParsingError(Invalid):
# class SCSIIdDescriptorParsingError(Invalid):
# class ResourceUpdateError(OSWinException):
# class DiskUpdateError(OSWinException):
#         def __init__(self, winerror=None):
#         def __init__(self, info='', com_error=None):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, message=None, wmi_exc=None):
#     def __init__(self, message=None, **kwargs):
# 
# Path: os_win/tests/unit/test_base.py
# class TestingException(Exception):
# class FakeWMIExc(exceptions.x_wmi):
# class BaseTestCase(base.BaseTestCase):
# class OsWinBaseTestCase(BaseTestCase):
#     def __init__(self, hresult=None):
#     def setUp(self):
#     def _patch_autospec_classes(self):
#     def setUp(self):
# 
# Path: os_win/utils/hostutils10.py
# LOG = logging.getLogger(__name__)
#     _HGS_NAMESPACE = '//%s/Root/Microsoft/Windows/Hgs'
#     _PCI_VENDOR_ID_REGEX = re.compile('VEN_(.*)&DEV', re.IGNORECASE)
#     _PCI_PRODUCT_ID_REGEX = re.compile('DEV_(.*)&SUBSYS', re.IGNORECASE)
#     _PCI_ADDRESS_REGEX = re.compile(r'\b\d+\b')
# class HostUtils10(hostutils.HostUtils):
#     def __init__(self, host='.'):
#     def _conn_hgs(self):
#     def is_host_guarded(self):
#     def supports_nested_virtualization(self):
#     def get_pci_passthrough_devices(self):
#     def _get_pci_device_address(self, pci_device_path):


import re
from unittest import mock
from os_win import exceptions
from os_win.tests.unit import test_base
from os_win.utils import hostutils10
#    under the License.





class HostUtils10TestCase(test_base.OsWinBaseTestCase):
    """Unit tests for the Hyper-V HostUtils10 class."""

    def setUp(self):
        super(HostUtils10TestCase, self).setUp()
        self._hostutils = hostutils10.HostUtils10()
        self._hostutils._conn_hgs_attr = mock.MagicMock()
        self._hostutils._conn_attr = mock.MagicMock()
        self._hostutils._conn_cimv2 = mock.MagicMock()

    @mock.patch.object(hostutils10.HostUtils10, '_get_wmi_conn')
    def test_conn_hgs(self, mock_get_wmi_conn):
        self._hostutils._conn_hgs_attr = None
        self.assertEqual(mock_get_wmi_conn.return_value,
                         self._hostutils._conn_hgs)

        mock_get_wmi_conn.assert_called_once_with(
            self._hostutils._HGS_NAMESPACE % self._hostutils._host)

    @mock.patch.object(hostutils10.HostUtils10, '_get_wmi_conn')
    def test_conn_hgs_no_namespace(self, mock_get_wmi_conn):
        self._hostutils._conn_hgs_attr = None

        mock_get_wmi_conn.side_effect = [exceptions.OSWinException]

# Path: os_win/exceptions.py
#     class WindowsError(Exception):
#     class x_wmi(Exception):
#     class x_wmi_timed_out(x_wmi):
# class OSWinException(Exception):
# class NotFound(OSWinException):
# class PciDeviceNotFound(NotFound):
# class HyperVException(OSWinException):
# class VHDResizeException(HyperVException):
# class HyperVAuthorizationException(HyperVException):
# class HyperVVMNotFoundException(NotFound, HyperVException):
# class HyperVPortNotFoundException(NotFound, HyperVException):
# class HyperVvNicNotFound(NotFound, HyperVException):
# class HyperVvSwitchNotFound(NotFound, HyperVException):
# class Invalid(OSWinException):
# class UnsupportedOperation(Invalid):
# class InvalidParameterValue(Invalid):
# class InvalidVMVersion(Invalid):
# class SMBException(OSWinException):
# class Win32Exception(OSWinException):
# class VHDException(OSWinException):
# class VHDWin32APIException(VHDException, Win32Exception):
# class FCException(OSWinException):
# class FCWin32Exception(FCException, Win32Exception):
# class WMIException(OSWinException):
# class WqlException(OSWinException):
# class ISCSITargetException(OSWinException):
# class ISCSITargetWMIException(ISCSITargetException, WMIException):
# class ISCSIInitiatorAPIException(Win32Exception):
# class ISCSILunNotAvailable(ISCSITargetException):
# class Win32IOException(Win32Exception):
# class DiskNotFound(NotFound):
# class HyperVRemoteFXException(HyperVException):
# class HyperVClusterException(HyperVException):
# class DNSException(OSWinException):
# class Timeout(OSWinException):
# class DNSZoneNotFound(NotFound, DNSException):
# class DNSZoneAlreadyExists(DNSException):
# class WMIJobFailed(HyperVException):
# class JobTerminateFailed(HyperVException):
# class ClusterException(OSWinException):
# class ClusterObjectNotFound(NotFound, ClusterException):
# class ClusterWin32Exception(ClusterException, Win32Exception):
# class ClusterGroupMigrationFailed(ClusterException):
# class ClusterGroupMigrationTimeOut(ClusterGroupMigrationFailed):
# class ClusterPropertyRetrieveFailed(ClusterException):
# class ClusterPropertyListEntryNotFound(ClusterPropertyRetrieveFailed):
# class ClusterPropertyListParsingError(ClusterPropertyRetrieveFailed):
# class SCSIPageParsingError(Invalid):
# class SCSIIdDescriptorParsingError(Invalid):
# class ResourceUpdateError(OSWinException):
# class DiskUpdateError(OSWinException):
#         def __init__(self, winerror=None):
#         def __init__(self, info='', com_error=None):
#     def __init__(self, message=None, **kwargs):
#     def __init__(self, message=None, wmi_exc=None):
#     def __init__(self, message=None, **kwargs):
# 
# Path: os_win/tests/unit/test_base.py
# class TestingException(Exception):
# class FakeWMIExc(exceptions.x_wmi):
# class BaseTestCase(base.BaseTestCase):
# class OsWinBaseTestCase(BaseTestCase):
#     def __init__(self, hresult=None):
#     def setUp(self):
#     def _patch_autospec_classes(self):
#     def setUp(self):
# 
# Path: os_win/utils/hostutils10.py
# LOG = logging.getLogger(__name__)
#     _HGS_NAMESPACE = '//%s/Root/Microsoft/Windows/Hgs'
#     _PCI_VENDOR_ID_REGEX = re.compile('VEN_(.*)&DEV', re.IGNORECASE)
#     _PCI_PRODUCT_ID_REGEX = re.compile('DEV_(.*)&SUBSYS', re.IGNORECASE)
#     _PCI_ADDRESS_REGEX = re.compile(r'\b\d+\b')
# class HostUtils10(hostutils.HostUtils):
#     def __init__(self, host='.'):
#     def _conn_hgs(self):
#     def is_host_guarded(self):
#     def supports_nested_virtualization(self):
#     def get_pci_passthrough_devices(self):
#     def _get_pci_device_address(self, pci_device_path):


# Path: os_win/tests/unit/utils/test_hostutils10.py
import re
from unittest import mock
from os_win import exceptions
from os_win.tests.unit import test_base
from os_win.utils import hostutils10

#    under the License.





class HostUtils10TestCase(test_base.OsWinBaseTestCase):
    """Unit tests for the Hyper-V HostUtils10 class."""

    def setUp(self):
        super(HostUtils10TestCase, self).setUp()
        self._hostutils = hostutils10.HostUtils10()
        self._hostutils._conn_hgs_attr = mock.MagicMock()
        self._hostutils._conn_attr = mock.MagicMock()
        self._hostutils._conn_cimv2 = mock.MagicMock()

    @mock.patch.object(hostutils10.HostUtils10, '_get_wmi_conn')
    def test_conn_hgs(self, mock_get_wmi_conn):
        self._hostutils._conn_hgs_attr = None
        self.assertEqual(mock_get_wmi_conn.return_value,
                         self._hostutils._conn_hgs)

        mock_get_wmi_conn.assert_called_once_with(
            self._hostutils._HGS_NAMESPACE % self._hostutils._host)

    @mock.patch.object(hostutils10.HostUtils10, '_get_wmi_conn')
    def test_conn_hgs_no_namespace(self, mock_get_wmi_conn):
        self._hostutils._conn_hgs_attr = None

        mock_get_wmi_conn.side_effect = [exceptions.OSWinException]

        self.assertRaises(exceptions.OSWinException,