Exemplo n.º 1
0
    def test_get_hibernate_timeout_scheme(self):
        '''
        Test to make sure we can get the hibernate timeout value with a
        specified scheme
        '''
        mock = MagicMock()
        mock.side_effect = [self.query_output]

        with patch.dict(powercfg.__salt__, {'cmd.run': mock}):
            ret = powercfg.get_hibernate_timeout(scheme='SCHEME_MIN')
            mock.assert_called_once_with(
                'powercfg /q SCHEME_MIN SUB_SLEEP HIBERNATEIDLE',
                python_shell=False)

            self.assertEqual({'ac': 30, 'dc': 15}, ret)
Exemplo n.º 2
0
    def test_get_hibernate_timeout_scheme(self):
        """
        Test to make sure we can get the hibernate timeout value with a
        specified scheme
        """
        mock = MagicMock()
        mock.side_effect = [self.query_output]

        with patch.dict(powercfg.__salt__, {"cmd.run": mock}):
            ret = powercfg.get_hibernate_timeout(scheme="SCHEME_MIN")
            mock.assert_called_once_with(
                "powercfg /q SCHEME_MIN SUB_SLEEP HIBERNATEIDLE", python_shell=False
            )

            self.assertEqual({"ac": 30, "dc": 15}, ret)
Exemplo n.º 3
0
    def test_get_hibernate_timeout(self):
        '''
            Test to make sure we can get 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}):
            ret = powercfg.get_hibernate_timeout()
            calls = [
                call('powercfg /getactivescheme', python_shell=False),
                call('powercfg /q 381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP HIBERNATEIDLE', python_shell=False)
            ]
            mock.assert_has_calls(calls)

            self.assertEqual({'ac': 30, 'dc': 15}, ret)
Exemplo n.º 4
0
    def test_get_hibernate_timeout(self):
        '''
            Test to make sure we can get 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}):
            ret = powercfg.get_hibernate_timeout()
            calls = [
                call('powercfg /getactivescheme', python_shell=False),
                call('powercfg /q 381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP HIBERNATEIDLE', python_shell=False)
            ]
            mock.assert_has_calls(calls)

            self.assertEqual({'ac': 30, 'dc': 15}, ret)
Exemplo n.º 5
0
    def test_get_hibernate_timeout(self):
        """
        Test to make sure we can get the hibernate timeout value
        """
        mock = MagicMock()
        mock.side_effect = [
            "Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)",
            self.query_output,
        ]

        with patch.dict(powercfg.__salt__, {"cmd.run": mock}):
            ret = powercfg.get_hibernate_timeout()
            calls = [
                call("powercfg /getactivescheme", python_shell=False),
                call(
                    "powercfg /q 381b4222-f694-41f0-9685-ff5bb260df2e SUB_SLEEP HIBERNATEIDLE",
                    python_shell=False,
                ),
            ]
            mock.assert_has_calls(calls)

            self.assertEqual({"ac": 30, "dc": 15}, ret)