Beispiel #1
0
 def test_set_hibernate_timeout(self):
     '''
         Test to make sure we can set the hibernate timeout value
     '''
     mock = MagicMock(return_value="")
     with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
         powercfg.set_hibernate_timeout(0, "dc")
         mock.assert_called_once_with('powercfg /x hibernate-timeout-dc 0', python_shell=False)
Beispiel #2
0
 def test_set_hibernate_timeout(self):
     '''
         Test to make sure we can set the hibernate timeout value
     '''
     mock = MagicMock(return_value="")
     with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
         powercfg.set_hibernate_timeout(0, "dc")
         mock.assert_called_once_with('powercfg /x hibernate-timeout-dc 0',
                                      python_shell=False)
Beispiel #3
0
    def test_set_hibernate_timeout_scheme(self):
        '''
        Test to make sure we can set the hibernate timeout value
        '''
        mock = MagicMock(return_value=0)
        mock.side_effect = [self.query_output]

        with patch.dict(powercfg.__salt__, {'cmd.retcode': mock}):
            powercfg.set_hibernate_timeout(0, 'dc', scheme='SCHEME_MIN')
            mock.assert_called_once_with(
                'powercfg /setdcvalueindex SCHEME_MIN SUB_SLEEP HIBERNATEIDLE 0',
                python_shell=False)
Beispiel #4
0
    def test_set_hibernate_timeout_scheme(self):
        '''
            Test to make sure we can set the hibernate timeout value
        '''
        mock = MagicMock()
        mock.side_effect = [self.query_ouput]

        with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
            powercfg.set_hibernate_timeout(0, "dc", scheme="SCHEME_MIN")
            calls = [
                call('powercfg /setdcvalueindex SCHEME_MIN SUB_SLEEP HIBERNATEIDLE 0', python_shell=False)
            ]
            mock.assert_has_calls(calls)
    def test_set_hibernate_timeout_scheme(self):
        """
        Test to make sure we can set the hibernate timeout value
        """
        mock = MagicMock(return_value=0)
        mock.side_effect = [self.query_output]

        with patch.dict(powercfg.__salt__, {"cmd.retcode": mock}):
            powercfg.set_hibernate_timeout(0, "dc", scheme="SCHEME_MIN")
            mock.assert_called_once_with(
                "powercfg /setdcvalueindex SCHEME_MIN SUB_SLEEP HIBERNATEIDLE 0",
                python_shell=False,
            )
Beispiel #6
0
    def test_set_hibernate_timeout(self):
        '''
            Test to make sure we can set the hibernate timeout value
        '''
        mock = MagicMock()
        mock.side_effect = ["Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)", self.query_ouput]

        with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
            powercfg.set_hibernate_timeout(0, "dc")
            calls = [
                call('powercfg /getactivescheme', python_shell=False),
                call('powercfg /setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP HIBERNATEIDLE 0', python_shell=False)
            ]
            mock.assert_has_calls(calls)
Beispiel #7
0
    def test_set_hibernate_timeout(self):
        '''
        Test to make sure we can set the hibernate timeout value
        '''
        mock = MagicMock(return_value=0)
        mock.side_effect = [
            'Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)',
            self.query_output
        ]

        mock_retcode = MagicMock(return_value=0)

        with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
            with patch.dict(powercfg.__salt__, {'cmd.retcode': mock_retcode}):
                powercfg.set_hibernate_timeout(0, 'dc')
                mock.assert_called_once_with('powercfg /getactivescheme',
                                             python_shell=False)
                mock_retcode.assert_called_once_with(
                    'powercfg /setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP HIBERNATEIDLE 0',
                    python_shell=False)
    def test_set_hibernate_timeout(self):
        """
        Test to make sure we can set the hibernate timeout value
        """
        mock = MagicMock(return_value=0)
        mock.side_effect = [
            "Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)",
            self.query_output,
        ]

        mock_retcode = MagicMock(return_value=0)

        with patch.dict(powercfg.__salt__, {"cmd.run": mock}):
            with patch.dict(powercfg.__salt__, {"cmd.retcode": mock_retcode}):
                powercfg.set_hibernate_timeout(0, "dc")
                mock.assert_called_once_with("powercfg /getactivescheme",
                                             python_shell=False)
                mock_retcode.assert_called_once_with(
                    "powercfg /setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e"
                    " SUB_SLEEP HIBERNATEIDLE 0",
                    python_shell=False,
                )