#NEWLINE# def test_present( self ) : #NEWLINE# #INDENT# '\n        Test to ensure the RackSpace queue exists.\n        ' #NEWLINE# name = 'myqueue' #NEWLINE# provider = 'my-pyrax' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'result' : True , #NEWLINE# 'comment' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# mock_dct = MagicMock ( side_effect = [ { #NEWLINE# #INDENT# provider : { #NEWLINE# #INDENT# 'salt' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# self : { #NEWLINE# #INDENT# 'salt' : False , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# provider : { #NEWLINE# #INDENT# 'salt' : False , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , False ] ) #NEWLINE# with patch . dict ( pyrax_queues . __salt__ , { #NEWLINE# #INDENT# 'cloud.action' : mock_dct , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = '{0} present.' . format ( name ) #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( pyrax_queues . present ( name , provider ) , ret ) #NEWLINE# with patch . dict ( pyrax_queues . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'Rackspace queue myqueue is set to be created.' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : None , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( pyrax_queues . present ( name , provider ) , ret ) #NEWLINE# #UNINDENT# with patch . dict ( pyrax_queues . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'Failed to create myqueue Rackspace queue.' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : False , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( pyrax_queues . present ( name , provider ) , ret )