

@mock_ec2
def test_eip_reassociate_nic():
    'reassociate EIP'
    conn = boto.connect_vpc('the_key', 'the_secret')
    vpc = conn.create_vpc('10.0.0.0/16')
    subnet = eni1.create_subnet(vpc.id, '10.0.0.0/18')
    eni1 = conn.create_network_interface(subnet.id)
    eni2 = conn.create_network_interface(subnet.id)
    eip = conn.allocate_address()
    conn.associate_address(network_interface_id=eni1.id, public_ip=eip.public_ip)
    conn.associate_address(network_interface_id=eni1.id, public_ip=eip.public_ip)
    with assert_raises(EC2ResponseError) as cm:
        conn.associate_address(network_interface_id=eni2.id, public_ip=eip.public_ip)
    cm.exception.code.should.equal('Resource.AlreadyAssociated')
    cm.exception.status.should.equal(400)
    cm.exception.request_id.should_not.be.none
    conn.associate_address.when.called_with(network_interface_id=eni2.id, public_ip=eip.public_ip, allow_reassociation=True).should_not.throw(EC2ResponseError)
    eip.release()
    eip = None

dataset/ETHPy150Open spulec/moto/tests/test_ec2/test_elastic_ip_addresses.py test_eip_reassociate_nic/VarMisuse@36/73 `conn`->`eni1`