<s> from __future__ import absolute_import <EOL> from salt . states import win_powercfg as powercfg <EOL> from salttesting import skipIf , TestCase <EOL> from salttesting . helpers import ensure_in_syspath <EOL> from salttesting . mock import ( <EOL> NO_MOCK , <EOL> NO_MOCK_REASON , <EOL> MagicMock , <EOL> patch <EOL> ) <EOL> ensure_in_syspath ( '<STR_LIT>' ) <EOL> powercfg . __salt__ = { } <EOL> @ skipIf ( NO_MOCK , NO_MOCK_REASON ) <EOL> class PowerCfgTestCase ( TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def test_set_monitor ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = { '<STR_LIT>' : { '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:0> } } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:result>' : True } <EOL> monitor_val = { "<STR_LIT>" : <NUM_LIT> , "<STR_LIT>" : <NUM_LIT> } <EOL> with patch . dict ( powercfg . __salt__ , { "<STR_LIT>" : MagicMock ( return_value = monitor_val ) , <EOL> "<STR_LIT>" : MagicMock ( return_value = True ) } ) : <EOL> self . assertEqual ( powercfg . set_timeout ( "<STR_LIT>" , <NUM_LIT:0> ) , ret ) <EOL> def test_set_monitor_already_set ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = { '<STR_LIT>' : { } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:result>' : True } <EOL> monitor_val = { "<STR_LIT>" : <NUM_LIT:0> , "<STR_LIT>" : <NUM_LIT:0> } <EOL> with patch . dict ( powercfg . __salt__ , { "<STR_LIT>" : MagicMock ( return_value = monitor_val ) , <EOL> "<STR_LIT>" : MagicMock ( return_value = True ) } ) : <EOL> self . assertEqual ( powercfg . set_timeout ( "<STR_LIT>" , <NUM_LIT:0> ) , ret ) <EOL> def test_fail_invalid_setting ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = { '<STR_LIT>' : { } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:result>' : False } <EOL> self . assertEqual ( powercfg . set_timeout ( "<STR_LIT>" , <NUM_LIT:0> ) , ret ) <EOL> def test_fail_invalid_power ( self ) : <EOL> '''<STR_LIT>''' <EOL> ret = { '<STR_LIT>' : { } , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:result>' : False } <EOL> self . assertEqual ( powercfg . set_timeout ( "<STR_LIT>" , <NUM_LIT:0> , power = "<STR_LIT>" ) , ret ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from integration import run_tests <EOL> run_tests ( PowerCfgTestCase , needs_daemon = False ) </s>
