#NEWLINE# def test_single( self ) : #NEWLINE# #INDENT# '\n            Test to execute single state function\n        ' #NEWLINE# ret = { #NEWLINE# #INDENT# 'pkg_|-name=vim_|-name=vim_|-installed' : list , #NEWLINE# #UNINDENT# } #NEWLINE# mock = MagicMock ( side_effect = [ 'A' , None , None , None , None ] ) #NEWLINE# with patch . object ( state , '_check_queue' , mock ) : #NEWLINE# #INDENT# self . assertEqual ( state . single ( 'pkg.installed' , ' name=vim' ) , 'A' ) #NEWLINE# self . assertEqual ( state . single ( 'pk' , 'name=vim' ) , 'Invalid function passed' ) #NEWLINE# with patch . dict ( state . __opts__ , { #NEWLINE# #INDENT# 'test' : 'install' , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# mock = MagicMock ( return_value = { #NEWLINE# #INDENT# 'test' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . object ( state , '_get_opts' , mock ) : #NEWLINE# #INDENT# mock = MagicMock ( return_value = True ) #NEWLINE# with patch . object ( salt . utils , 'test_mode' , mock ) : #NEWLINE# #INDENT# self . assertRaises ( SaltInvocationError , state . single , 'pkg.installed' , 'name=vim' , pillar = 'A' ) #NEWLINE# MockState . State . flag = True #NEWLINE# self . assertTrue ( state . single ( 'pkg.installed' , 'name=vim' ) ) #NEWLINE# MockState . State . flag = False #NEWLINE# self . assertDictEqual ( state . single ( 'pkg.installed' , 'name=vim' ) , mock )