def test_enable(self): """ Test if it enable an interface. """ # Test with enabled interface with patch.object(win_ip, "is_enabled", return_value=True): self.assertTrue(win_ip.enable("Ethernet")) mock_cmd = MagicMock() with patch.object(win_ip, "is_enabled", side_effect=[False, True ]), patch.dict(win_ip.__salt__, {"cmd.run": mock_cmd}): self.assertTrue(win_ip.enable("Ethernet")) mock_cmd.called_once_with( [ "netsh", "interface", "set", "interface", "name=Ethernet", "admin=ENABLED", ], python_shell=False, )
def test_enable(self): ''' Test if it enable an interface. ''' mock_cmd = MagicMock(return_value=ETHERNET_ENABLE) with patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_ip.enable('Ethernet')) mock_cmd = MagicMock(return_value='Connect state: Disconnected') with patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertFalse(win_ip.enable('Ethernet'))
def test_enable(self): """ Test if it enable an interface. """ mock_cmd = MagicMock(return_value=ETHERNET_ENABLE) with patch.dict(win_ip.__salt__, {"cmd.run": mock_cmd}): self.assertTrue(win_ip.enable("Ethernet")) mock_cmd = MagicMock(return_value="Connect state: Disconnected") with patch.dict(win_ip.__salt__, {"cmd.run": mock_cmd}): self.assertFalse(win_ip.enable("Ethernet"))
def test_enable(self): ''' Test if it enable an interface. ''' # Test with enabled interface with patch.object(win_ip, 'is_enabled', return_value=True): self.assertTrue(win_ip.enable('Ethernet')) mock_cmd = MagicMock() with patch.object(win_ip, 'is_enabled', side_effect=[False, True]), \ patch.dict(win_ip.__salt__, {'cmd.run': mock_cmd}): self.assertTrue(win_ip.enable('Ethernet')) mock_cmd.called_once_with([ 'netsh', 'interface', 'set', 'interface', 'name=Ethernet', 'admin=ENABLED' ], python_shell=False)