#NEWLINE# def test_mod_watch( self ) : #NEWLINE# #INDENT# '\n            Test to the service watcher, called to invoke the watch command.\n        ' #NEWLINE# ret = [ { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Service is already stopped' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Unable to trigger watch for service.stack' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : False , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Service is set to be started' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : None , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'changes' : { #NEWLINE# #INDENT# 'salt' : 'salt' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : 'Service started' , #NEWLINE# 'name' : 'salt' , #NEWLINE# 'result' : 'salt' , #NEWLINE# #UNINDENT# } ] #NEWLINE# mock = MagicMock ( return_value = False ) #NEWLINE# with patch . dict ( service . __salt__ , { #NEWLINE# #INDENT# 'service.status' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( service . mod_watch ( 'salt' , 'dead' ) , ret [ 0 ] ) #NEWLINE# with patch . dict ( service . __salt__ , { #NEWLINE# #INDENT# 'service.start' : func , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch . dict ( service . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( service . mod_watch ( 'salt' , 'running' ) , ret [ 2 ] ) #NEWLINE# #UNINDENT# with patch . dict ( service . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertDictEqual ( service . mod_watch ( 'salt' , 'running' ) , mock [ 3 ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . assertDictEqual ( service . mod_watch ( 'salt' , 'stack' ) , ret [ 1 ] )