'Test post-association logic.'

def _do_test_associate_floating_ip(self, orig_instance_uuid):

    new_instance = objects.Instance(uuid=FAKE_UUID)
    def fake_associate(*args, **kwargs):
        return orig_instance_uuid
    def fake_instance_get_by_uuid(context, instance_uuid, columns_to_join=None, use_slave=None):
        if (instance_uuid == orig_instance_uuid):
            self.assertIn('extra.flavor', columns_to_join)
        return fake_instance.fake_db_instance(uuid=instance_uuid)
    def fake_get_nw_info(ctxt, instance):
        class FakeNWInfo(object, ):
            def json(self):
                pass
        return FakeNWInfo()
    if orig_instance_uuid:
        expected_updated_instances = [new_instance.uuid, orig_instance_uuid]
    else:
        expected_updated_instances = [new_instance.uuid]
    def fake_instance_info_cache_update(context, instance_uuid, cache):
        self.assertEqual(instance_uuid, expected_updated_instances.pop())
        return fake_info_cache
    def fake_update_instance_cache_with_nw_info(api, context, instance, nw_info=None, update_cells=True):
        return
    with test.nested(mock.patch.object(floating_ips.FloatingIP, 'associate_floating_ip', fake_associate), mock.patch.object(self.network_api.db, 'instance_get_by_uuid', fake_instance_get_by_uuid), mock.patch.object(self.network_api, '_get_instance_nw_info', fake_get_nw_info), mock.patch.object(self.network_api.db, 'instance_info_cache_update', fake_instance_info_cache_update), mock.patch.object(base_api, 'update_instance_cache_with_nw_info', fake_update_instance_cache_with_nw_info)):
        self.network_api.associate_floating_ip(self.context, new_instance, '172.24.4.225', '10.0.0.2')
