@mock_ec2
def test_eip_reassociate():
 conn = boto.connect_ec2(u'the_key', u'the_secret')
 reservation = conn.run_instances(u'ami-1234abcd', min_count=2)
 (instance1, instance2) = reservation.instances
 eip = conn.allocate_address()
 conn.associate_address(instance_id=instance1.id, public_ip=eip.public_ip)
 conn.associate_address(instance_id=instance1.id, public_ip=eip.public_ip)
 with assert_raises(EC2ResponseError) as cm:
  conn.associate_address(instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=False)
 cm.exception.code.should.equal(u'Resource.AlreadyAssociated')
 cm.exception.status.should.equal(400)
 cm.exception.request_id.should_not.be.none
 conn.associate_address.when.called_with(instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=True).should_not.throw(EC2ResponseError)
 eip.release()
 eip = None
 instance1.terminate()
 instance2.terminate()

@ mock_ec2 def test_eip_reassociate ( ) : conn = boto . connect_ec2 ( u'the_key' , u'the_secret' ) reservation = conn . run_instances ( u'ami-1234abcd' , min_count = 2 ) ( instance1 , instance2 ) = reservation . instances eip = conn . allocate_address ( ) conn . associate_address ( instance_id = instance1 . id , public_ip = eip . public_ip ) conn . associate_address ( instance_id = instance1 . id , public_ip = eip . public_ip ) with assert_raises ( EC2ResponseError ) as cm : conn . associate_address ( instance_id = instance2 . id , public_ip = eip . public_ip , allow_reassociation = False ) cm . exception . code . should . equal ( u'Resource.AlreadyAssociated' ) cm . exception . status . should . equal ( 400 ) cm . exception . request_id . should_not . be . none conn . associate_address . when . called_with ( instance_id = instance2 . id , public_ip = eip . public_ip , allow_reassociation = True ) . should_not . throw ( EC2ResponseError ) eip . release ( ) eip = None instance1 . terminate ( ) instance2 . terminate ( )
reassociate eip .