示例#1
0
 def test_set_disk_timeout(self):
     '''
         Test to make sure we can set the disk timeout value
     '''
     mock = MagicMock(return_value="")
     with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
         powercfg.set_disk_timeout(0, "dc")
         mock.assert_called_once_with('powercfg /x disk-timeout-dc 0', python_shell=False)
示例#2
0
 def test_set_disk_timeout(self):
     '''
         Test to make sure we can set the disk timeout value
     '''
     mock = MagicMock(return_value="")
     with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
         powercfg.set_disk_timeout(0, "dc")
         mock.assert_called_once_with('powercfg /x disk-timeout-dc 0',
                                      python_shell=False)
示例#3
0
    def test_set_disk_timeout(self):
        '''
            Test to make sure we can set the disk 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_disk_timeout(0, "dc")
            calls = [
                call('powercfg /getactivescheme', python_shell=False),
                call('powercfg /setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e SUB_DISK DISKIDLE 0', python_shell=False)
            ]
            mock.assert_has_calls(calls)
示例#4
0
    def test_set_disk_timeout(self):
        '''
        Test to make sure we can set the disk timeout value
        '''
        mock = MagicMock()
        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_disk_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_DISK DISKIDLE 0',
                    python_shell=False)
示例#5
0
    def test_set_disk_timeout(self):
        """
        Test to make sure we can set the disk timeout value
        """
        mock = MagicMock()
        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_disk_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_DISK DISKIDLE 0",
                    python_shell=False,
                )