#NEWLINE# def test_create_tags( self ) : #NEWLINE# #INDENT# self . db_api . get_item_by_id . return_value = { #NEWLINE# #INDENT# 'id' : 'fake' , #NEWLINE# #UNINDENT# } #NEWLINE# resp = self . execute ( 'CreateTags' , { #NEWLINE# #INDENT# 'ResourceId.1' : fakes . ID_EC2_VPC_1 , #NEWLINE# 'ResourceId.2' : fakes . ID_EC2_SUBNET_1 , #NEWLINE# 'Tag.1.Key' : 'private' , #NEWLINE# 'Tag.1.Value' : '' , #NEWLINE# 'Tag.2.Key' : 'admin' , #NEWLINE# 'Tag.2.Value' : 'John Smith' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'return' : True , #NEWLINE# #UNINDENT# } , resp ) #NEWLINE# self . assertEqual ( 1 , r_t . db_api . add_tags . call_count ) #NEWLINE# self . assertEqual ( 2 , len ( self . db_api . add_tags . call_args ) ) #NEWLINE# self . assertThat ( self . db_api . add_tags . call_args [ 0 ] [ 1 ] , matchers . ListMatches ( [ { #NEWLINE# #INDENT# 'item_id' : fakes . ID_EC2_VPC_1 , #NEWLINE# 'key' : 'private' , #NEWLINE# 'value' : '' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'item_id' : fakes . ID_EC2_SUBNET_1 , #NEWLINE# 'key' : 'private' , #NEWLINE# 'value' : '' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'item_id' : fakes . ID_EC2_VPC_1 , #NEWLINE# 'key' : 'admin' , #NEWLINE# 'value' : 'John Smith' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'item_id' : fakes . ID_EC2_SUBNET_1 , #NEWLINE# 'key' : 'admin' , #NEWLINE# 'value' : 'John Smith' , #NEWLINE# #UNINDENT# } ] , orderless_lists = True ) ) #NEWLINE# resource_ids = [ fakes . random_ec2_id ( r_t ) for r_t in [ 'dopt' , 'ami' , 'aki' , 'ari' , 'cgw' , 'i' , 'igw' , 'eni' , 'rtb' , 'snap' , 'subnet' , 'sg' , 'vgw' , 'vol' , 'vpc' , 'vpn' ] ] #NEWLINE# self . assertEqual ( len ( resource_ids ) , len ( tag_api . RESOURCE_TYPES ) ) #NEWLINE# params = { ( 'ResourceId.%s' % num ) : r_id for ( num , r_id ) in enumerate ( resource_ids ) } #NEWLINE# params . update ( { #NEWLINE# #INDENT# 'Tag.1.Key' : 'tag' , #NEWLINE# 'Tag.1.Value' : 'value' , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = self . execute ( 'CreateTags' , params ) #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'return' : True , #NEWLINE# #UNINDENT# } , resp ) #NEWLINE# self . db_api . get_item_by_id . return_value = None #NEWLINE# resp = self . execute ( 'CreateTags' , { #NEWLINE# #INDENT# 'ResourceId.1' : fakes . ID_EC2_IMAGE_1 , #NEWLINE# 'ResourceId.2' : fakes . ID_EC2_IMAGE_AKI_1 , #NEWLINE# 'ResourceId.3' : fakes . ID_EC2_IMAGE_ARI_1 , #NEWLINE# 'Tag.1.Key' : 'Oracle RAC node' , #NEWLINE# 'Tag.1.Value' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'return' : True , #NEWLINE# #UNINDENT# } , resp )