#NEWLINE# @ patch ( 'boto3.resource' ) #NEWLINE# def test_targets( self , botoresource ) : #NEWLINE# #INDENT# instances = [ StubInstance ( id = 'i-abc123' , image_id = 'ami-def456' , private_ip_address = '1.2.3.4' , state = { #NEWLINE# #INDENT# 'Name' : 'running' , #NEWLINE# #UNINDENT# } , tags = [ { #NEWLINE# #INDENT# 'Key' : 'foo' , #NEWLINE# 'Value' : 'bar' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'Key' : 'Name' , #NEWLINE# 'Value' : 'servername' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'Key' : 'Environment' , #NEWLINE# 'Value' : 'live1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'Key' : 'aws:autoscaling:groupName' , #NEWLINE# 'Value' : 'groupname' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'Key' : 'opsworks:instance' , #NEWLINE# 'Value' : 'frontend1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'Key' : 'opsworks:stack' , #NEWLINE# 'Value' : 'stack1' , #NEWLINE# #UNINDENT# } ] ) , StubInstance ( id = 2 , state = { #NEWLINE# #INDENT# 'Name' : 'notrunning' , #NEWLINE# #UNINDENT# } ) ] #NEWLINE# ec2 = Mock ( ) #NEWLINE# ec2 . instances . all = Mock ( return_value = instances ) #NEWLINE# botoresource . return_value = ec2 #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'name:servername' : [ '1.2.3.4' ] , #NEWLINE# 'asg:groupname' : [ '1.2.3.4' ] , #NEWLINE# 'i-abc123' : [ '1.2.3.4' ] , #NEWLINE# 'ami-def456' : [ '1.2.3.4' ] , #NEWLINE# 'env:live1' : [ '1.2.3.4' ] , #NEWLINE# 'oin:frontend1' : [ '1.2.3.4' ] , #NEWLINE# 'ois:stack1' : [ '1.2.3.4' ] , #NEWLINE# #UNINDENT# } , ish . aws . targets ( ) )