'Create a fake instance of Webapp and related models from ES data.'

def fake_object(self, data):

    is_packaged = (data['app_type'] != mkt.ADDON_WEBAPP_HOSTED)
    is_privileged = (data['app_type'] == mkt.ADDON_WEBAPP_PRIVILEGED)
    obj = Webapp(id=data['id'], app_slug=data['app_slug'], is_packaged=is_packaged, icon_type='image/png')
    obj.listed_authors = []
    obj._current_version = Version()
    obj._current_version.addon = obj
    obj._current_version._developer_name = data['author']
    obj._current_version.supported_locales = data['supported_locales']
    obj._current_version.version = data['current_version']
    obj._latest_version = Version()
    obj._latest_version.is_privileged = is_privileged
    obj._geodata = Geodata()
    obj.all_previews = [Preview(id=p['id'], modified=self.to_datetime(p['modified']), filetype=p['filetype'], sizes=p.get('sizes', {})) for p in data['previews']]
    obj.categories = data['category']
    obj.tags_list = data['tags']
    obj._device_types = [DEVICE_TYPES[d] for d in data['device']]
    obj._is_disabled = data['is_disabled']
    self._attach_fields(obj, data, ('created', 'default_locale', 'guid', 'icon_hash', 'is_escalated', 'is_offline', 'last_updated', 'manifest_url', 'modified', 'premium_type', 'promo_img_hash', 'regions', 'reviewed', 'status', 'tv_featured'))
    self._attach_translations(obj, data, ('name', 'description', 'homepage', 'support_email', 'support_url'))
    if data.get('group_translations'):
        self._attach_translations(obj, data, ('group',))
    else:
        obj.group_translations = None
    ESTranslationSerializerField.attach_translations(obj._current_version, data, 'release_notes', target_name='releasenotes')
    obj.public_stats = data['has_public_stats']
    obj.get_excluded_region_ids = (lambda : data['region_exclusions'])
    if obj.is_premium():
        Webapp.attach_premiums([obj])
    obj.es_data = data
    return obj
