def test_set_static_dns_no_action(self): """ Test if it set static DNS configuration on a Windows NIC. """ # Test passing nothing self.assertDictEqual( win_ip.set_static_dns("Ethernet"), { "DNS Server": "No Changes", "Interface": "Ethernet" }, ) # Test passing None self.assertDictEqual( win_ip.set_static_dns("Ethernet", None), { "DNS Server": "No Changes", "Interface": "Ethernet" }, ) # Test passing string None self.assertDictEqual( win_ip.set_static_dns("Ethernet", "None"), { "DNS Server": "No Changes", "Interface": "Ethernet" }, )
def test_set_static_dns_clear(self): """ Test if it set static DNS configuration on a Windows NIC. """ mock_cmd = MagicMock() with patch.dict(win_ip.__salt__, {"cmd.run": mock_cmd}): self.assertDictEqual( win_ip.set_static_dns("Ethernet", []), { "DNS Server": [], "Interface": "Ethernet" }, ) mock_cmd.assert_called_once_with( [ "netsh", "interface", "ip", "set", "dns", "name=Ethernet", "source=static", "address=none", ], python_shell=False, )
def test_set_static_dns(self): ''' Test if it set static DNS configuration on a Windows NIC. ''' mock_cmd = MagicMock() with patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertDictEqual( win_ip.set_static_dns('Ethernet', '192.168.1.252', '192.168.1.253'), { 'DNS Server': ('192.168.1.252', '192.168.1.253'), 'Interface': 'Ethernet' }) mock_cmd.assert_has_calls([ call([ 'netsh', 'interface', 'ip', 'set', 'dns', 'name=Ethernet', 'source=static', 'address=192.168.1.252', 'register=primary' ], python_shell=False), call([ 'netsh', 'interface', 'ip', 'add', 'dns', 'name=Ethernet', 'address=192.168.1.253', 'index=2' ], python_shell=False) ])
def test_set_static_dns(self): """ Test if it set static DNS configuration on a Windows NIC. """ mock_cmd = MagicMock(return_value=ETHERNET_CONFIG) with patch.dict(win_ip.__salt__, {"cmd.run": mock_cmd}): self.assertDictEqual( win_ip.set_static_dns("Ethernet", "192.168.1.252", "192.168.1.253"), {"DNS Server": ("192.168.1.252", "192.168.1.253"), "Interface": "Ethernet"}, )
def test_set_static_dns_no_action(self): ''' Test if it set static DNS configuration on a Windows NIC. ''' # Test passing nothing self.assertDictEqual(win_ip.set_static_dns('Ethernet'), { 'DNS Server': 'No Changes', 'Interface': 'Ethernet' }) # Test passing None self.assertDictEqual(win_ip.set_static_dns('Ethernet', None), { 'DNS Server': 'No Changes', 'Interface': 'Ethernet' }) # Test passing string None self.assertDictEqual(win_ip.set_static_dns('Ethernet', 'None'), { 'DNS Server': 'No Changes', 'Interface': 'Ethernet' })
def test_set_static_dns(self): ''' Test if it set static DNS configuration on a Windows NIC. ''' mock_cmd = MagicMock(return_value=ETHERNET_CONFIG) with patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertDictEqual(win_ip.set_static_dns('Ethernet', '192.168.1.252', '192.168.1.253'), {'DNS Server': ('192.168.1.252', '192.168.1.253'), 'Interface': 'Ethernet'})
def test_set_static_dns_clear(self): ''' Test if it set static DNS configuration on a Windows NIC. ''' mock_cmd = MagicMock() with patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertDictEqual(win_ip.set_static_dns('Ethernet', []), { 'DNS Server': [], 'Interface': 'Ethernet' }) mock_cmd.assert_called_once_with([ 'netsh', 'interface', 'ip', 'set', 'dns', 'name=Ethernet', 'source=static', 'address=none' ], python_shell=False)
def test_set_static_dns(self): """ Test if it set static DNS configuration on a Windows NIC. """ mock_cmd = MagicMock() with patch.dict(win_ip.__salt__, {"cmd.run": mock_cmd}): self.assertDictEqual( win_ip.set_static_dns("Ethernet", "192.168.1.252", "192.168.1.253"), { "DNS Server": ("192.168.1.252", "192.168.1.253"), "Interface": "Ethernet", }, ) mock_cmd.assert_has_calls([ call( [ "netsh", "interface", "ip", "set", "dns", "name=Ethernet", "source=static", "address=192.168.1.252", "register=primary", ], python_shell=False, ), call( [ "netsh", "interface", "ip", "add", "dns", "name=Ethernet", "address=192.168.1.253", "index=2", ], python_shell=False, ), ])