diff --git a/salt/modules/win_powercfg.py b/salt/modules/win_powercfg.py index 3fbe2b4722..aecf9bedf0 100644 --- a/salt/modules/win_powercfg.py +++ b/salt/modules/win_powercfg.py @@ -31,7 +31,7 @@ def __virtual__(): def _get_current_scheme(): cmd = "powercfg /getactivescheme" - out = __salt__['cmd.run'](cmd, python_shell=False) + out = __salt__['cmd.run'](cmd, python_shell=False) matches = re.search(r"GUID: (.*) \(", out) return matches.groups()[0].strip() @@ -42,7 +42,7 @@ def _get_powercfg_minute_values(scheme, guid, subguid): ''' cmd = "powercfg /q {0} {1} {2}".format(scheme, guid, subguid) out = __salt__['cmd.run'](cmd, python_shell=False) - raw_settings = re.findall(r"Power Setting Index: ([0-9a-fx]+)", out) + raw_settings = re.findall(r"Power Setting Index: ([0-9a-fx]+)", out) return {"ac": int(raw_settings[0], 0) / 60, "dc": int(raw_settings[1], 0) / 60} @@ -185,5 +185,3 @@ def get_hibernate_timeout(): salt '*' powercfg.get_hibernate_timeout ''' return _get_powercfg_minute_values(_get_current_scheme(), "SUB_SLEEP", "HIBERNATEIDLE") - - diff --git a/salt/states/win_powercfg.py b/salt/states/win_powercfg.py index eb8e98cf82..df6c4cedf3 100644 --- a/salt/states/win_powercfg.py +++ b/salt/states/win_powercfg.py @@ -86,10 +86,10 @@ def set_timeout(name, value, power="ac"): values = check_func() if values[power] == value: - comment.append ("{0} {1} is already set with the value {2}.".format(name, power, value)) + comment.append("{0} {1} is already set with the value {2}.".format(name, power, value)) else: ret['changes'] = {name: {power: value}} set_func(value, power) ret['comment'] = ' '.join(comment) - return ret \ No newline at end of file + return ret diff --git a/tests/unit/modules/win_powercfg_test.py b/tests/unit/modules/win_powercfg_test.py index a08ab9df83..98d9c09150 100644 --- a/tests/unit/modules/win_powercfg_test.py +++ b/tests/unit/modules/win_powercfg_test.py @@ -21,6 +21,7 @@ ensure_in_syspath('../../') powercfg.__salt__ = {} + @skipIf(NO_MOCK, NO_MOCK_REASON) class PowerCfgTestCase(TestCase): query_ouput = '''Subgroup GUID: 238c9fa8-0aad-41ed-83f4-97be242c8f20 (Hibernate) @@ -64,7 +65,6 @@ class PowerCfgTestCase(TestCase): powercfg.set_standby_timeout(0, "dc") mock.assert_called_once_with('powercfg /x standby-timeout-dc 0', python_shell=False) - def test_set_hibernate_timeout(self): ''' Test to make sure we can set the hibernate timeout value @@ -74,7 +74,6 @@ class PowerCfgTestCase(TestCase): powercfg.set_hibernate_timeout(0, "dc") mock.assert_called_once_with('powercfg /x hibernate-timeout-dc 0', python_shell=False) - def test_get_monitor_timeout(self): ''' Test to make sure we can get the monitor timeout value @@ -92,7 +91,6 @@ class PowerCfgTestCase(TestCase): self.assertEqual({'ac': 30, 'dc': 15}, ret) - def test_get_disk_timeout(self): ''' Test to make sure we can get the disk timeout value diff --git a/tests/unit/states/win_powercfg_test.py b/tests/unit/states/win_powercfg_test.py index 4ab587cc1d..45de9f0b12 100644 --- a/tests/unit/states/win_powercfg_test.py +++ b/tests/unit/states/win_powercfg_test.py @@ -20,6 +20,7 @@ ensure_in_syspath('../../') powercfg.__salt__ = {} + @skipIf(NO_MOCK, NO_MOCK_REASON) class PowerCfgTestCase(TestCase): ''' @@ -54,7 +55,6 @@ class PowerCfgTestCase(TestCase): ret = {'changes': {}, 'comment': 'fakesetting is not a valid setting', 'name': 'fakesetting', 'result': False} self.assertEqual(powercfg.set_timeout("fakesetting", 0), ret) - def test_fail_invalid_power(self): ''' Test to make sure we can set the monitor timeout value