#NEWLINE# def test_power( self ) : #NEWLINE# #INDENT# '\n        Test to request power state change\n        ' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : 'power_on' , #NEWLINE# 'result' : True , #NEWLINE# 'comment' : '' , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# mock = MagicMock ( return_value = 'on' ) #NEWLINE# with patch . dict ( ipmi . __salt__ , { #NEWLINE# #INDENT# 'ipmi.get_power' : mock , #NEWLINE# 'ipmi.set_power' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'system already in this state' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( ipmi . power ( ) , ret ) #NEWLINE# with patch . dict ( ipmi . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'changed system power' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'name' : 'off' , #NEWLINE# 'comment' : comt , #NEWLINE# 'result' : True , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# 'new' : 'off' , #NEWLINE# 'old' : 'on' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( ipmi . power ( 'off' ) , ret ) #NEWLINE# #UNINDENT# with patch . dict ( ipmi . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'would power: off system' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : None , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( ipmi . power ( 'off' ) , ret )