#NEWLINE# def test_present( self ) : #NEWLINE# #INDENT# '\n        Test to ensure the cache cluster exists.\n        ' #NEWLINE# name = 'myelasticache' #NEWLINE# engine = 'redis' #NEWLINE# cache_node_type = 'cache.t1.micro' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'result' : None , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# mock = MagicMock ( side_effect = [ None , False , False , True ] ) #NEWLINE# mock_bool = MagicMock ( return_value = False ) #NEWLINE# with patch . dict ( boto_elasticache . __salt__ , { #NEWLINE# #INDENT# 'boto_elasticache.get_config' : mock , #NEWLINE# 'boto_elasticache.create' : mock_bool , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'Failed to retrieve cache cluster info from AWS.' #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( boto_elasticache . present ( name , engine , cache_node_type ) , ret ) #NEWLINE# with patch . dict ( boto_elasticache . __opts__ , { #NEWLINE# #INDENT# 'test' : True , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'Cache cluster {0} is set to be created.' . format ( name ) #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( boto_elasticache . present ( name , engine , cache_node_type ) , ret ) #NEWLINE# #UNINDENT# with patch . dict ( boto_elasticache . __opts__ , { #NEWLINE# #INDENT# 'test' : False , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# comt = 'Failed to create {0} cache cluster.' . format ( name ) #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : False , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( boto_elasticache . present ( name , engine , cache_node_type ) , ret ) #NEWLINE# comt = 'Cache cluster {0} is present.' . format ( mock_bool ) #NEWLINE# ret . update ( { #NEWLINE# #INDENT# 'comment' : comt , #NEWLINE# 'result' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( boto_elasticache . present ( name , engine , cache_node_type ) , ret )