<commit_before># -*- coding: utf-8 -*-
'''
    :codeauthor: :email:`<NAME> <<EMAIL>>`
'''

# Import Python Libs
from __future__ import absolute_import

# Import Salt Testing Libs
from salttesting import TestCase, skipIf
from salttesting.mock import (
    MagicMock,
    patch,
    NO_MOCK,
    NO_MOCK_REASON
)

from salttesting.helpers import ensure_in_syspath

ensure_in_syspath('../../')

# Import Salt Libs
from salt.modules import win_dns_client

# Globals
win_dns_client.__salt__ = {}
win_dns_client.__context__ = {}


class Mockwmi(object):
    '''
    Mock wmi class
    '''
    NetConnectionID = 'Local Area Connection'
    Index = 0
    DNSServerSearchOrder = ['10.1.1.10']
    Description = 'Local Area Connection'
    DHCPEnabled = True

    def __init__(self):
        self.netenabled = None
        self.index = None
        self.ipenabled = None

    @staticmethod
    def WMI():
        '''
        Mock WMI method
        '''
        return Mockwmi()

    def Win32_NetworkAdapter(self, NetEnabled=True):
        '''
        Mock Win32_NetworkAdapter method
        '''
        self.netenabled = NetEnabled
        return [Mockwmi()]

    def Win32_NetworkAdapterConfiguration(self, Index=0, IPEnabled=1):
        '''
        Mock Win32_NetworkAdapterConfiguration method
        '''
        self.index = Index
        self.ipenabled = IPEnabled
        return [Mockwmi()]

win_dns_client.wmi = Mockwmi


@skipIf(NO_MOCK, NO_MOCK_REASON)
class WinDnsClientTestCase(TestCase):
    '''
    Test cases for salt.modules.win_dns_client
    '''
    # 'get_dns_servers' function tests: 1

    def test_get_dns_servers(self):
        '''
        Test if it return a list of the configured DNS servers
        of the specified interface.
        '''
        with patch('salt.utils.winapi.Com', MagicMock()):
            self.assertListEqual(win_dns_client.get_dns_servers
                                 ('Local Area Connection'), ['10.1.1.10'])

            self.assertFalse(win_dns_client.get_dns_servers('Ethernet'))<commit_msg>adding win_dns_client unit test case<commit_after># -*- coding: utf-8 -*-
'''
    :codeauthor: :email:`<NAME> <<EMAIL>>`
'''

# Import Python Libs
from __future__ import absolute_import

# Import Salt Testing Libs
from salttesting import TestCase, skipIf
from salttesting.mock import (
    MagicMock,
    patch,
    NO_MOCK,
    NO_MOCK_REASON
)

from salttesting.helpers import ensure_in_syspath

ensure_in_syspath('../../')

# Import Salt Libs
from salt.modules import win_dns_client

# Globals
win_dns_client.__salt__ = {}
win_dns_client.__context__ = {}


class Mockwmi(object):
    '''
    Mock wmi class
    '''
    NetConnectionID = 'Local Area Connection'
    Index = 0
    DNSServerSearchOrder = ['10.1.1.10']
    Description = 'Local Area Connection'
    DHCPEnabled = True

    def __init__(self):
        self.netenabled = None
        self.index = None
        self.ipenabled = None

    @staticmethod
    def WMI():
        '''
        Mock WMI method
        '''
        return Mockwmi()

    def Win32_NetworkAdapter(self, NetEnabled=True):
        '''
        Mock Win32_NetworkAdapter method
        '''
        self.netenabled = NetEnabled
        return [Mockwmi()]

    def Win32_NetworkAdapterConfiguration(self, Index=0, IPEnabled=1):
        '''
        Mock Win32_NetworkAdapterConfiguration method
        '''
        self.index = Index
        self.ipenabled = IPEnabled
        return [Mockwmi()]


class Mockwinapi(object):
    '''
    Mock winapi class
    '''
    def __init__(self):
        pass

    @staticmethod
    def Com():
        '''
        Mock Com method
        '''
        return True

win_dns_client.salt.utils.winapi = Mockwinapi
win_dns_client.wmi = Mockwmi


@skipIf(NO_MOCK, NO_MOCK_REASON)
class WinDnsClientTestCase(TestCase):
    '''
    Test cases for salt.modules.win_dns_client
    '''
    # 'get_dns_servers' function tests: 1

    def test_get_dns_servers(self):
        '''
        Test if it return a list of the configured DNS servers
        of the specified interface.
        '''
        with patch('salt.utils.winapi.Com', MagicMock()):
            self.assertListEqual(win_dns_client.get_dns_servers
                                 ('Local Area Connection'), ['10.1.1.10'])

            self.assertFalse(win_dns_client.get_dns_servers('Ethernet'))
{'fraction_non_alphanumeric': 0.10289389067524116, 'fraction_numerical': 0.011483693155718878, 'mean_word_length': 2.523462783171521, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2877690', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1362, 'n_words': 305}