# 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/baseutils.py
# LOG = logging.getLogger(__name__)
#     _WMI_CONS = {}
# class BaseUtils(object):
# class BaseUtilsVirt(BaseUtils):
# class SynchronizedMeta(type):
#     def _get_wmi_obj(self, moniker, **kwargs):
#     def _get_wmi_conn(self, moniker, **kwargs):
#     def __init__(self, host='.'):
#     def _conn(self):
#     def _compat_conn(self):
#     def _vs_man_svc(self):
#     def _get_wmi_compat_conn(self, moniker, **kwargs):
#     def _get_wmi_obj(self, moniker, compatibility_mode=False, **kwargs):
#     def __init__(cls, cls_name, bases, attrs):
#     def _synchronize(func, cls_name, rlock):
#         def wrapper(*args, **kwargs):


from unittest import mock
from os_win.tests.unit import test_base
from os_win.utils import baseutils
import six
import importlib
                                                 **kwargs)

    def test_get_wmi_conn_kwargs(self):
        self.utils._WMI_CONS.clear()
        self._check_get_wmi_conn(privileges=mock.sentinel.privileges)
        self.assertNotIn(mock.sentinel.moniker, baseutils.BaseUtils._WMI_CONS)

    def test_get_wmi_conn(self):
        self._check_get_wmi_conn()
        self.assertIn(mock.sentinel.moniker, baseutils.BaseUtils._WMI_CONS)

    @mock.patch.object(baseutils.BaseUtils, '_get_wmi_obj')
    @mock.patch.object(baseutils, 'sys')
    def test_get_wmi_conn_cached(self, mock_sys, mock_get_wmi_obj):
        mock_sys.platform = 'win32'
        baseutils.BaseUtils._WMI_CONS[mock.sentinel.moniker] = (
            mock.sentinel.conn)
        result = self.utils._get_wmi_conn(mock.sentinel.moniker)

        self.assertEqual(mock.sentinel.conn, result)
        self.assertFalse(mock_get_wmi_obj.called)

    @mock.patch.object(baseutils, 'sys')
    def test_get_wmi_conn_linux(self, mock_sys):
        mock_sys.platform = 'linux'
        result = self.utils._get_wmi_conn(mock.sentinel.moniker)

        self.assertIsNone(result)



# 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/baseutils.py
# LOG = logging.getLogger(__name__)
#     _WMI_CONS = {}
# class BaseUtils(object):
# class BaseUtilsVirt(BaseUtils):
# class SynchronizedMeta(type):
#     def _get_wmi_obj(self, moniker, **kwargs):
#     def _get_wmi_conn(self, moniker, **kwargs):
#     def __init__(self, host='.'):
#     def _conn(self):
#     def _compat_conn(self):
#     def _vs_man_svc(self):
#     def _get_wmi_compat_conn(self, moniker, **kwargs):
#     def _get_wmi_obj(self, moniker, compatibility_mode=False, **kwargs):
#     def __init__(cls, cls_name, bases, attrs):
#     def _synchronize(func, cls_name, rlock):
#         def wrapper(*args, **kwargs):


# Path: os_win/tests/unit/utils/test_baseutils.py
from unittest import mock
from os_win.tests.unit import test_base
from os_win.utils import baseutils
import six
import importlib

                                                 **kwargs)

    def test_get_wmi_conn_kwargs(self):
        self.utils._WMI_CONS.clear()
        self._check_get_wmi_conn(privileges=mock.sentinel.privileges)
        self.assertNotIn(mock.sentinel.moniker, baseutils.BaseUtils._WMI_CONS)

    def test_get_wmi_conn(self):
        self._check_get_wmi_conn()
        self.assertIn(mock.sentinel.moniker, baseutils.BaseUtils._WMI_CONS)

    @mock.patch.object(baseutils.BaseUtils, '_get_wmi_obj')
    @mock.patch.object(baseutils, 'sys')
    def test_get_wmi_conn_cached(self, mock_sys, mock_get_wmi_obj):
        mock_sys.platform = 'win32'
        baseutils.BaseUtils._WMI_CONS[mock.sentinel.moniker] = (
            mock.sentinel.conn)
        result = self.utils._get_wmi_conn(mock.sentinel.moniker)

        self.assertEqual(mock.sentinel.conn, result)
        self.assertFalse(mock_get_wmi_obj.called)

    @mock.patch.object(baseutils, 'sys')
    def test_get_wmi_conn_linux(self, mock_sys):
        mock_sys.platform = 'linux'
        result = self.utils._get_wmi_conn(mock.sentinel.moniker)

        self.assertIsNone(result)



class BaseUtilsVirtTestCase(test_base.OsWinBaseTestCase):