Exemplo n.º 1
0
    def test_add_dns(self):
        '''
        Test if it add the DNS server to the network interface.
        '''
        with patch('salt.utils.winapi.Com', MagicMock()):
            with patch.object(self.WMI,
                              'Win32_NetworkAdapter',
                              return_value=[Mockwmi()]):
                with patch.object(self.WMI,
                                  'Win32_NetworkAdapterConfiguration',
                                  return_value=[Mockwmi()]):
                    self.assertFalse(
                        win_dns_client.add_dns('10.1.1.10', 'Ethernet'))

                    self.assertTrue(
                        win_dns_client.add_dns('10.1.1.10',
                                               'Local Area Connection'))

        with patch.object(win_dns_client, 'get_dns_servers',
                          MagicMock(return_value=['10.1.1.10'])):
            with patch.dict(win_dns_client.__salt__,
                            {'cmd.retcode': MagicMock(return_value=0)}):
                self.assertTrue(
                    win_dns_client.add_dns('10.1.1.0',
                                           'Local Area Connection'))
    def test_add_dns(self):
        """
        Test if it add the DNS server to the network interface.
        """
        with patch("salt.utils.winapi.Com",
                   MagicMock()), patch.object(
                       self.WMI,
                       "Win32_NetworkAdapter",
                       return_value=[Mockwmi()]), patch.object(
                           self.WMI,
                           "Win32_NetworkAdapterConfiguration",
                           return_value=[Mockwmi()]), patch.object(
                               wmi, "WMI", Mock(return_value=self.WMI)):
            self.assertFalse(win_dns_client.add_dns("10.1.1.10", "Ethernet"))

            self.assertTrue(
                win_dns_client.add_dns("10.1.1.10", "Local Area Connection"))

        with patch.object(win_dns_client, "get_dns_servers",
                          MagicMock(return_value=["10.1.1.10"])), patch.dict(
                              win_dns_client.__salt__,
                              {"cmd.retcode": MagicMock(return_value=0)
                               }), patch.object(wmi, "WMI",
                                                Mock(return_value=self.WMI)):
            self.assertTrue(
                win_dns_client.add_dns("10.1.1.0", "Local Area Connection"))
Exemplo n.º 3
0
    def test_add_dns(self):
        '''
        Test if it add the DNS server to the network interface.
        '''
        with patch('salt.utils.winapi.Com', MagicMock()):
            self.assertFalse(win_dns_client.add_dns('10.1.1.10', 'Ethernet'))

            self.assertTrue(win_dns_client.add_dns('10.1.1.10',
                                                   'Local Area Connection'))

            with patch.dict(win_dns_client.__salt__,
                            {'cmd.retcode': MagicMock(return_value=0)}):
                self.assertTrue(win_dns_client.add_dns('10.1.1.0',
                                                       'Local Area Connection'))
Exemplo n.º 4
0
    def test_add_dns(self):
        '''
        Test if it add the DNS server to the network interface.
        '''
        with patch('salt.utils.winapi.Com', MagicMock()):
            with patch.object(WMI, 'Win32_NetworkAdapter',
                              return_value=[Mockwmi()]):
                with patch.object(WMI, 'Win32_NetworkAdapterConfiguration',
                                  return_value=[Mockwmi()]):
                    self.assertFalse(win_dns_client.add_dns('10.1.1.10',
                                                            'Ethernet'))

                    self.assertTrue(win_dns_client.add_dns
                                    ('10.1.1.10', 'Local Area Connection'))

        with patch.object(win_dns_client, 'get_dns_servers',
                          MagicMock(return_value=['10.1.1.10'])):
            with patch.dict(win_dns_client.__salt__,
                            {'cmd.retcode': MagicMock(return_value=0)}):
                self.assertTrue(win_dns_client.add_dns('10.1.1.0',
                                                       'Local Area Connection'))