示例#1
0
    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,
        )
示例#2
0
    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'))
示例#3
0
    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"))
示例#4
0
    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)