Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Collect image dimensions from Europeana (#2782)

rwidom501aa84aef84
diff --git a/catalog/DAGs.md b/catalog/DAGs.md
index 1aee77483..7774008ef 100644
--- a/catalog/DAGs.md
+++ b/catalog/DAGs.md
@@ -108,7 +108,6 @@ The following are DAGs grouped by their primary tag:
| DAG ID | Schedule Interval |
| --------------------------------------------------------------------------------------- | ----------------- |
-| [`europeana_reingestion_workflow`](#europeana_reingestion_workflow) | `@weekly` |
| [`flickr_reingestion_workflow`](#flickr_reingestion_workflow) | `@weekly` |
| [`metropolitan_museum_reingestion_workflow`](#metropolitan_museum_reingestion_workflow) | `@weekly` |
| [`phylopic_reingestion_workflow`](#phylopic_reingestion_workflow) | `@weekly` |
@@ -126,7 +125,6 @@ The following is documentation associated with each DAG (where available):
1. [`check_silenced_dags`](#check_silenced_dags)
1. [`create_filtered_audio_index`](#create_filtered_audio_index)
1. [`create_filtered_image_index`](#create_filtered_image_index)
-1. [`europeana_reingestion_workflow`](#europeana_reingestion_workflow)
1. [`europeana_workflow`](#europeana_workflow)
1. [`finnish_museums_workflow`](#finnish_museums_workflow)
1. [`flickr_audit_sub_provider_workflow`](#flickr_audit_sub_provider_workflow)
@@ -442,16 +440,6 @@ parameter is only for use by the data refresh DAG and should not be used when
manually triggering the DAG unless you are absolutely certain of what you are
doing.
-## `europeana_reingestion_workflow`
-
-Content Provider: Europeana
-
-ETL Process: Use the API to identify all CC licensed images.
-
-Output: TSV file containing the images and the respective meta-data.
-
-Notes: https://pro.europeana.eu/page/search
-
## `europeana_workflow`
Content Provider: Europeana
diff --git a/catalog/dags/providers/provider_api_scripts/europeana.py b/catalog/dags/providers/provider_api_scripts/europeana.py
index 3b93e3402..8a4ea6876 100644
--- a/catalog/dags/providers/provider_api_scripts/europeana.py
+++ b/catalog/dags/providers/provider_api_scripts/europeana.py
@@ -60,6 +60,7 @@ class EuropeanaRecordBuilder:
def get_record_data(self, data: dict) -> dict | None:
try:
+ item_data = data.get("item_webresource", {})
record = {
"foreign_landing_url": self._get_foreign_landing_url(data),
"url": self._get_image_url(data),
@@ -67,7 +68,9 @@ class EuropeanaRecordBuilder:
"meta_data": self._get_meta_data_dict(data),
"title": self._get_title(data),
"license_info": self._get_license_info(data),
- }
+ "filetype": self._get_filetype(item_data),
+ "filesize": self._get_filesize(item_data),
+ } | self._get_image_dimensions(item_data)
data_providers = set(record["meta_data"]["dataProvider"])
eligible_sub_providers = {
@@ -81,13 +84,12 @@ class EuropeanaRecordBuilder:
f"image with foreign ID {record['foreign_identifier']}"
)
- return record | {
- "source": (
- eligible_sub_providers.pop()
- if len(eligible_sub_providers) == 1
- else EuropeanaDataIngester.providers["image"]
- )
- }
+ record["source"] = (
+ eligible_sub_providers.pop()
+ if len(eligible_sub_providers) == 1
+ else EuropeanaDataIngester.providers["image"]
+ )
+ return {k: v for k, v in record.items() if v is not None}
except EmptyRequiredFieldException as exc:
logger.warning("A required field was empty", exc_info=exc)
return None
@@ -129,6 +131,22 @@ class EuropeanaRecordBuilder:
return europeana_url
+ def _get_image_dimensions(self, item_data: dict) -> dict:
+ width = item_data.get("ebucoreWidth")
+ height = item_data.get("ebucoreHeight")
+ if width and height:
+ return {"width": width, "height": height}
+ return {}
+
+ def _get_filetype(self, item_data: dict) -> str:
+ if filetype := item_data.get("ebucoreHasMimeType"):
+ if "/" in filetype:
+ return item_data.get("ebucoreHasMimeType").split("/")[1]
+ return filetype
+
+ def _get_filesize(self, item_data: dict) -> int:
+ return item_data.get("ebucoreFileByteSize")
+
def _get_meta_data_dict(self, data: dict) -> dict:
meta_data = {
"country": data.get("country"),
@@ -159,7 +177,7 @@ class EuropeanaDataIngester(ProviderDataIngester):
providers = {"image": prov.EUROPEANA_DEFAULT_PROVIDER}
sub_providers = prov.EUROPEANA_SUB_PROVIDERS
endpoint = "https://api.europeana.eu/record/v2/search.json?"
- delay = 30
+ delay = 3
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -188,6 +206,9 @@ class EuropeanaDataIngester(ProviderDataIngester):
"cursor": "*",
}
+ self.item_params = {
+ "wskey": Variable.get("API_KEY_EUROPEANA", default_var=None)
+ }
self.record_builder = EuropeanaRecordBuilder()
def _get_timestamp_query_param(self, date):
@@ -223,7 +244,48 @@ class EuropeanaDataIngester(ProviderDataIngester):
return response_json.get("items")
def get_record_data(self, data: dict) -> dict:
- return self.record_builder.get_record_data(data)
+ return self.record_builder.get_record_data(
+ data | {"item_webresource": self._get_additional_item_data(data)}
+ )
+
+ def _get_id_and_url(self, data) -> tuple:
+ try:
+ return (
+ self.record_builder._get_foreign_identifier(data),
+ self.record_builder._get_image_url(data),
+ )
+ except EmptyRequiredFieldException as exc:
+ logger.warning("Missing id or url", exc_info=exc)
+ return (None, None)
+
+ def _get_additional_item_data(self, data) -> dict:
+ # The Europeana requester uses a 3 second delay to avoid overwhelming the item
+ # endpoint and to maintain at least a 30 second break between calls to the
+ # search endpoint.
+ (item_id, url) = self._get_id_and_url(data)
+ if not (item_id and url):
+ return {}
+ item_response = self.get_response_json(
+ query_params=self.item_params,
+ endpoint=f"https://api.europeana.eu/record/v2{item_id}.json",
+ )
+ if not item_response or not item_response.get("success"):
+ logger.warning("Item request failed no response or ``success != True``")
+ return {}
+ aggregations = item_response.get("object", {}).get("aggregations", [])
+ for aggregation in aggregations:
+ return next(
+ (
+ resource
+ for resource in aggregation.get("webResources", [])
+ if (
+ resource.get("ebucoreHasMimeType", "").startswith("image")
+ and resource.get("about") == url
+ )
+ ),
+ {},
+ )
+ return {}
def main(date):
diff --git a/catalog/dags/providers/provider_reingestion_workflows.py b/catalog/dags/providers/provider_reingestion_workflows.py
index 6bd3ca82a..58f3c97d0 100644
--- a/catalog/dags/providers/provider_reingestion_workflows.py
+++ b/catalog/dags/providers/provider_reingestion_workflows.py
@@ -1,7 +1,6 @@
from dataclasses import dataclass
from datetime import timedelta
-from providers.provider_api_scripts.europeana import EuropeanaDataIngester
from providers.provider_api_scripts.flickr import FlickrDataIngester
from providers.provider_api_scripts.metropolitan_museum import MetMuseumDataIngester
from providers.provider_api_scripts.phylopic import PhylopicDataIngester
@@ -56,15 +55,6 @@ class ProviderReingestionWorkflow(ProviderWorkflow):
PROVIDER_REINGESTION_WORKFLOWS = [
- ProviderReingestionWorkflow(
- # 60 total reingestion days
- ingester_class=EuropeanaDataIngester,
- max_active_tasks=3,
- pull_timeout=timedelta(hours=16),
- daily_list_length=7,
- one_month_list_length=12,
- three_month_list_length=40,
- ),
ProviderReingestionWorkflow(
# 128 total reingestion days
ingester_class=FlickrDataIngester,
diff --git a/catalog/dags/providers/provider_workflows.py b/catalog/dags/providers/provider_workflows.py
index 1c97930eb..0d50c0352 100644
--- a/catalog/dags/providers/provider_workflows.py
+++ b/catalog/dags/providers/provider_workflows.py
@@ -205,6 +205,7 @@ PROVIDER_WORKFLOWS = [
start_date=datetime(2022, 10, 27),
schedule_string="@daily",
dated=True,
+ pull_timeout=timedelta(days=3),
),
ProviderWorkflow(
ingester_class=FinnishMuseumsDataIngester,
diff --git a/catalog/tests/dags/providers/provider_api_scripts/resources/europeana/item_full.json b/catalog/tests/dags/providers/provider_api_scripts/resources/europeana/item_full.json
new file mode 100644
index 000000000..a6b6ef49c
--- /dev/null
+++ b/catalog/tests/dags/providers/provider_api_scripts/resources/europeana/item_full.json
@@ -0,0 +1,202 @@
+{
+ "apikey": "test",
+ "success": true,
+ "statsDuration": 170,
+ "requestNumber": 999,
+ "object": {
+ "about": "/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "aggregations": [
+ {
+ "about": "/aggregation/provider/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "edmDataProvider": {
+ "def": ["http://data.europeana.eu/organization/1482250000004511854"]
+ },
+ "edmIsShownBy": "https://images.memorix.nl/nda/thumb/fullsize/010a31d7-9316-54d7-6ad0-83b9914688d9.jpg",
+ "edmIsShownAt": "http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6",
+ "edmObject": "https://images.memorix.nl/nda/thumb/640x480/010a31d7-9316-54d7-6ad0-83b9914688d9.jpg",
+ "edmProvider": {
+ "def": ["http://data.europeana.eu/organization/1482250000004671093"]
+ },
+ "edmRights": {
+ "def": ["http://creativecommons.org/publicdomain/zero/1.0/"]
+ },
+ "edmUgc": "false",
+ "aggregatedCHO": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "webResources": [
+ {
+ "about": "happy_url",
+ "textAttributionSnippet": " - https://www.europeana.eu/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6. Fotovlucht Vliegbasis Soesterberg. Nederlands Instituut voor Militaire Historie - http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6. CC0 - http://creativecommons.org/publicdomain/zero/1.0/",
+ "htmlAttributionSnippet": "<link rel='stylesheet' type='text/css' href='https://api.europeana.eu/attribution/style.css'/><dl class='europeana-attribution' lang='en'><dt>Creator</dt><dd lang=''>Fotovlucht Vliegbasis Soesterberg</dd><dt>Institution</dt><dd lang=''><a href='http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6' target='_blank' rel='noopener'>Nederlands Instituut voor Militaire Historie</a></dd><dt>Country</dt><dd lang=''>Netherlands</dd><dt>Rights</dt><dd><a href='http://creativecommons.org/publicdomain/zero/1.0/' target='_blank' rel='noopener'><span class='icon-cc'/><span class='icon-zero'/>CC0</a></dd></dl>",
+ "ebucoreHasMimeType": "image/jpeg",
+ "ebucoreFileByteSize": 36272,
+ "ebucoreWidth": 381,
+ "ebucoreHeight": 480,
+ "edmHasColorSpace": "sRGB",
+ "edmComponentColor": [
+ "#FF6347",
+ "#556B2F",
+ "#E9967A",
+ "#A0522D",
+ "#FFEBCD",
+ "#DAA520"
+ ],
+ "ebucoreOrientation": "portrait"
+ },
+ {
+ "about": "http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6",
+ "textAttributionSnippet": " - https://www.europeana.eu/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6. Fotovlucht Vliegbasis Soesterberg. Nederlands Instituut voor Militaire Historie - http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6. CC0 - http://creativecommons.org/publicdomain/zero/1.0/",
+ "htmlAttributionSnippet": "<link rel='stylesheet' type='text/css' href='https://api.europeana.eu/attribution/style.css'/><dl class='europeana-attribution' lang='en'><dt>Creator</dt><dd lang=''>Fotovlucht Vliegbasis Soesterberg</dd><dt>Institution</dt><dd lang=''><a href='http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6' target='_blank' rel='noopener'>Nederlands Instituut voor Militaire Historie</a></dd><dt>Country</dt><dd lang=''>Netherlands</dd><dt>Rights</dt><dd><a href='http://creativecommons.org/publicdomain/zero/1.0/' target='_blank' rel='noopener'><span class='icon-cc'/><span class='icon-zero'/>CC0</a></dd></dl>",
+ "ebucoreHasMimeType": "text/html",
+ "ebucoreFileByteSize": 0
+ },
+ {
+ "about": "https://images.memorix.nl/nda/thumb/fullsize/010a31d7-9316-54d7-6ad0-83b9914688d9.jpg",
+ "textAttributionSnippet": " - https://www.europeana.eu/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6. Fotovlucht Vliegbasis Soesterberg. Nederlands Instituut voor Militaire Historie - http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6. CC0 - http://creativecommons.org/publicdomain/zero/1.0/",
+ "htmlAttributionSnippet": "<link rel='stylesheet' type='text/css' href='https://api.europeana.eu/attribution/style.css'/><dl class='europeana-attribution' lang='en'><dt>Creator</dt><dd lang=''>Fotovlucht Vliegbasis Soesterberg</dd><dt>Institution</dt><dd lang=''><a href='http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6' target='_blank' rel='noopener'>Nederlands Instituut voor Militaire Historie</a></dd><dt>Country</dt><dd lang=''>Netherlands</dd><dt>Rights</dt><dd><a href='http://creativecommons.org/publicdomain/zero/1.0/' target='_blank' rel='noopener'><span class='icon-cc'/><span class='icon-zero'/>CC0</a></dd></dl>",
+ "dctermsIsReferencedBy": [
+ "https://iiif.europeana.eu/presentation/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6/manifest"
+ ],
+ "ebucoreHasMimeType": "image/jpeg",
+ "ebucoreFileByteSize": 157858,
+ "ebucoreWidth": 795,
+ "ebucoreHeight": 1000,
+ "edmHasColorSpace": "sRGB",
+ "edmComponentColor": [
+ "#FFEBCD",
+ "#8B0000",
+ "#FFFAFA",
+ "#FFEFD5",
+ "#FFD700",
+ "#E9967A"
+ ],
+ "ebucoreOrientation": "portrait"
+ },
+ {
+ "about": "https://iiif.europeana.eu/presentation/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6/manifest",
+ "rdfType": "http://iiif.io/api/presentation/3#Manifest"
+ }
+ ]
+ }
+ ],
+ "edmDatasetName": ["2021650_Ag_NL_DigitaleCollectie_nimh"],
+ "europeanaAggregation": {
+ "about": "/aggregation/europeana/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "aggregatedCHO": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "edmCountry": {
+ "def": ["Netherlands"]
+ },
+ "edmLanguage": {
+ "def": ["nl"]
+ },
+ "edmPreview": "https://api.europeana.eu/thumbnail/v2/url.json?uri=https%3A%2F%2Fimages.memorix.nl%2Fnda%2Fthumb%2F640x480%2F010a31d7-9316-54d7-6ad0-83b9914688d9.jpg&type=IMAGE",
+ "edmLandingPage": "https://www.europeana.eu/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "dqvHasQualityAnnotation": [
+ "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6#contentTier",
+ "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6#metadataTier"
+ ]
+ },
+ "europeanaCollectionName": ["2021650_Ag_NL_DigitaleCollectie_nimh"],
+ "europeanaCompleteness": 10,
+ "organizations": [
+ {
+ "about": "http://data.europeana.eu/organization/1482250000004671093",
+ "prefLabel": {
+ "en": ["Dutch Collections for Europe"]
+ }
+ },
+ {
+ "about": "http://data.europeana.eu/organization/1482250000004511854",
+ "prefLabel": {
+ "en": ["Netherlands Institute for Military History"],
+ "nl": ["Nederlands Instituut voor Militaire Historie"]
+ }
+ }
+ ],
+ "providedCHOs": [
+ {
+ "about": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6"
+ }
+ ],
+ "proxies": [
+ {
+ "about": "/proxy/europeana/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "dcIdentifier": {
+ "def": [
+ "http://nimh-beeldbank.defensie.nl/memorix/0000ee69-1b9e-6823-478f-c88af61736c6"
+ ]
+ },
+ "proxyIn": [
+ "/aggregation/europeana/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6"
+ ],
+ "proxyFor": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "lineage": [
+ "/proxy/provider/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6"
+ ],
+ "europeanaProxy": true
+ },
+ {
+ "about": "/proxy/provider/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "dcCreator": {
+ "def": ["Fotovlucht Vliegbasis Soesterberg"]
+ },
+ "dcDescription": {
+ "def": [
+ "Een Agusta Bell AB-412SP van 303 Squadron boven het betonningsvaartuig Terschelling (1988-) van Rijkswaterstaat, ingedeeld bij de Kustwacht, tijdens de\n reddingsoefening 'Get Wet'.&nbsp;",
+ "Een Agusta Bell AB-412SP van het 303 squadron van de Koninklijke Luchtmacht hangt boven het schip de 'Terschelling' van de kustwacht, tijdens de oefening 'Get wet' boven de\n Noordzee."
+ ]
+ },
+ "dcIdentifier": {
+ "def": ["2156_018660"]
+ },
+ "dcSubject": {
+ "def": [
+ "R-02",
+ "Koninklijke Luchtmacht, squadrons Koninklijke Luchtmacht, 303 Squadron (KLu)",
+ "kustwacht"
+ ]
+ },
+ "dcType": {
+ "def": ["Digitaal fotobestand"]
+ },
+ "dctermsCreated": {
+ "def": ["2003-09-03 /"]
+ },
+ "dctermsIsPartOf": {
+ "def": ["Luchtfotoarchief Vliegbasis Soesterberg"]
+ },
+ "dctermsSpatial": {
+ "def": ["Noordzee, Nederland"]
+ },
+ "proxyIn": [
+ "/aggregation/provider/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6"
+ ],
+ "proxyFor": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6",
+ "edmType": "IMAGE",
+ "europeanaProxy": false
+ }
+ ],
+ "qualityAnnotations": [
+ {
+ "about": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6#contentTier",
+ "created": "2023-08-01T14:07:27.421851Z",
+ "target": [
+ "/aggregation/provider/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6"
+ ],
+ "body": "http://www.europeana.eu/schemas/epf/contentTier2"
+ },
+ {
+ "about": "/item/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6#metadataTier",
+ "created": "2023-08-01T14:07:27.421873Z",
+ "target": [
+ "/aggregation/provider/2021650/memorix_0000ee69_1b9e_6823_478f_c88af61736c6"
+ ],
+ "body": "http://www.europeana.eu/schemas/epf/metadataTier0"
+ }
+ ],
+ "timestamp_created": "2022-03-02T15:35:41.563Z",
+ "timestamp_created_epoch": 1646235341563,
+ "timestamp_update": "2023-08-01T14:02:32.057Z",
+ "timestamp_update_epoch": 1690898552057,
+ "type": "IMAGE"
+ }
+}
diff --git a/catalog/tests/dags/providers/provider_api_scripts/resources/europeana/item_not_first_webresource.json b/catalog/tests/dags/providers/provider_api_scripts/resources/europeana/item_not_first_webresource.json
new file mode 100644
index 000000000..0d31b6885
--- /dev/null
+++ b/catalog/tests/dags/providers/provider_api_scripts/resources/europeana/item_not_first_webresource.json
@@ -0,0 +1,486 @@
+{
+ "apikey": "ounitece",
+ "success": true,
+ "statsDuration": 257,
+ "requestNumber": 999,
+ "object": {
+ "about": "/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "agents": [
+ {
+ "about": "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent4",
+ "prefLabel": { "es": ["Quinto y Giui, Agustín, 1774-1827"] },
+ "owlSameAs": [
+ "https://www.cortesaragon.es/fondoHistorico/aut/FDHA20130006956"
+ ]
+ },
+ {
+ "about": "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent6",
+ "prefLabel": { "es": ["López, Vicente, 1772-1850"] },
+ "owlSameAs": [
+ "https://www.cortesaragon.es/fondoHistorico/aut/FDHA20130006901"
+ ]
+ }
+ ],
+ "aggregations": [
+ {
+ "about": "/aggregation/provider/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "edmDataProvider": {
+ "def": ["http://data.europeana.eu/organization/1482250000004503496"]
+ },
+ "edmIsShownBy": "https://www.cortesaragon.es/fondoHistorico/i18n/catalogo_imagenes/imagen_id.do?idImagen=122319",
+ "edmIsShownAt": "https://www.cortesaragon.es/fondoHistorico/es/consulta/registro.do?id=2323",
+ "edmObject": "https://www.cortesaragon.es/fondoHistorico/i18n/catalogo_imagenes/imagen_id.do?idImagen=122319",
+ "edmProvider": {
+ "def": ["http://data.europeana.eu/organization/1482250000004671126"]
+ },
+ "edmRights": {
+ "def": ["http://creativecommons.org/licenses/by-nc-nd/4.0/"]
+ },
+ "edmUgc": "false",
+ "aggregatedCHO": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "webResources": [
+ {
+ "about": "https://www.cortesaragon.es/fondoHistorico/es/consulta/registro.do?id=2323",
+ "textAttributionSnippet": "(en) Portrait of Augustine of Fifth and Guiu [Graphic Material] - https://www.europeana.eu/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0. . Fondo Documental Histórico de las Cortes de Aragón - https://www.cortesaragon.es/fondoHistorico/es/consulta/registro.do?id=2323. CC BY-NC-ND - http://creativecommons.org/licenses/by-nc-nd/4.0/",
+ "htmlAttributionSnippet": "<link rel='stylesheet' type='text/css' href='https://api.europeana.eu/attribution/style.css'/><dl class='europeana-attribution' lang='en'><dt>Title</dt><dd lang='en'><a href='http://data.europeana.eu/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0' target='_blank' rel='noopener'>Portrait of Augustine of Fifth and Guiu [Graphic Material]</a></dd><dt>Creator</dt><dt>Date</dt><dd lang=''>1801; 1853</dd><dt>Institution</dt><dd lang=''><a href='https://www.cortesaragon.es/fondoHistorico/es/consulta/registro.do?id=2323' target='_blank' rel='noopener'>Fondo Documental Histórico de las Cortes de Aragón</a></dd><dt>Country</dt><dd lang=''>Spain</dd><dt>Rights</dt><dd><a href='http://creativecommons.org/licenses/by-nc-nd/4.0/' target='_blank' rel='noopener'><span class='icon-cc'/><span class='icon-by'/><span class='icon-nc'/><span class='icon-nd'/>CC BY-NC-ND</a></dd></dl>",
+ "ebucoreHasMimeType": "text/html",
+ "ebucoreFileByteSize": 0
+ },
+ {
+ "about": "happy_url",
+ "textAttributionSnippet": "(en) Portrait of Augustine of Fifth and Guiu [Graphic Material] - https://www.europeana.eu/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0. . Fondo Documental Histórico de las Cortes de Aragón - https://www.cortesaragon.es/fondoHistorico/es/consulta/registro.do?id=2323. CC BY-NC-ND - http://creativecommons.org/licenses/by-nc-nd/4.0/",
+ "htmlAttributionSnippet": "<link rel='stylesheet' type='text/css' href='https://api.europeana.eu/attribution/style.css'/><dl class='europeana-attribution' lang='en'><dt>Title</dt><dd lang='en'><a href='http://data.europeana.eu/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0' target='_blank' rel='noopener'>Portrait of Augustine of Fifth and Guiu [Graphic Material]</a></dd><dt>Creator</dt><dt>Date</dt><dd lang=''>1801; 1853</dd><dt>Institution</dt><dd lang=''><a href='https://www.cortesaragon.es/fondoHistorico/es/consulta/registro.do?id=2323' target='_blank' rel='noopener'>Fondo Documental Histórico de las Cortes de Aragón</a></dd><dt>Country</dt><dd lang=''>Spain</dd><dt>Rights</dt><dd><a href='http://creativecommons.org/licenses/by-nc-nd/4.0/' target='_blank' rel='noopener'><span class='icon-cc'/><span class='icon-by'/><span class='icon-nc'/><span class='icon-nd'/>CC BY-NC-ND</a></dd></dl>",
+ "dctermsIsReferencedBy": [
+ "https://iiif.europeana.eu/presentation/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0/manifest"
+ ],
+ "ebucoreHasMimeType": "image/jpeg",
+ "ebucoreFileByteSize": 604829,
+ "ebucoreWidth": 772,
+ "ebucoreHeight": 1024,
+ "edmHasColorSpace": "sRGB",
+ "edmComponentColor": [
+ "#CD5C5C",
+ "#BC8F8F",
+ "#FFE4C4",
+ "#696969",
+ "#E9967A",
+ "#D2B48C"
+ ],
+ "ebucoreOrientation": "portrait"
+ },
+ {
+ "about": "https://iiif.europeana.eu/presentation/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0/manifest",
+ "rdfType": "http://iiif.io/api/presentation/3#Manifest"
+ }
+ ]
+ }
+ ],
+ "concepts": [
+ {
+ "about": "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent3",
+ "prefLabel": { "es": ["López, Vicente, 1772-1850, Taller de"] },
+ "broader": [
+ "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent6"
+ ],
+ "closeMatch": [
+ "https://www.cortesaragon.es/fondoHistorico/aut/FDHA20130006918"
+ ]
+ },
+ {
+ "about": "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent5",
+ "prefLabel": { "es": ["Dibujos a lápiz Conte-1853-España"] },
+ "broader": [
+ "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent7"
+ ],
+ "closeMatch": [
+ "https://www.cortesaragon.es/fondoHistorico/aut/FDHA20130006963"
+ ]
+ },
+ {
+ "about": "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent7",
+ "prefLabel": { "es": ["Dibujos a lápiz Conte"] },
+ "closeMatch": [
+ "https://www.cortesaragon.es/fondoHistorico/aut/FDHA20130006970"
+ ]
+ }
+ ],
+ "edmDatasetName": ["571_Hispana_FondoHistoricoCortesAragon"],
+ "europeanaAggregation": {
+ "about": "/aggregation/europeana/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "aggregatedCHO": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "edmCountry": { "def": ["Spain"] },
+ "edmLanguage": { "def": ["es"] },
+ "edmPreview": "https://api.europeana.eu/thumbnail/v2/url.json?uri=https%3A%2F%2Fwww.cortesaragon.es%2FfondoHistorico%2Fi18n%2Fcatalogo_imagenes%2Fimagen_id.do%3FidImagen%3D122319&type=IMAGE",
+ "edmLandingPage": "https://www.europeana.eu/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "dqvHasQualityAnnotation": [
+ "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0#contentTier",
+ "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0#metadataTier"
+ ]
+ },
+ "europeanaCollectionName": ["571_Hispana_FondoHistoricoCortesAragon"],
+ "europeanaCompleteness": 7,
+ "licenses": [
+ {
+ "about": "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent2",
+ "odrlInheritFrom": "http://creativecommons.org/licenses/by-nc-nd/4.0/"
+ }
+ ],
+ "organizations": [
+ {
+ "about": "http://data.europeana.eu/organization/1482250000004671126",
+ "prefLabel": { "en": ["Hispana"] }
+ },
+ {
+ "about": "http://data.europeana.eu/organization/1482250000004503496",
+ "prefLabel": {
+ "en": ["Historical Documentary Fund of the Cortes de Aragón"],
+ "es": ["Fondo Documental Histórico de las Cortes de Aragón"]
+ }
+ }
+ ],
+ "places": [
+ {
+ "about": "http://data.europeana.eu/place/83",
+ "prefLabel": {
+ "de": ["Spanien"],
+ "fi": ["Espanja"],
+ "ru": ["Испания"],
+ "pt": ["Espanha"],
+ "bg": ["Испания"],
+ "lt": ["Ispanija"],
+ "hr": ["Španjolska"],
+ "lv": ["Spānija"],
+ "fr": ["Espagne"],
+ "hu": ["Spanyolország"],
+ "sk": ["Španielsko"],
+ "sl": ["Španija"],
+ "ga": ["An Spáinn"],
+ "ca": ["Espanya"],
+ "sv": ["Spanien"],
+ "mt": ["Spanja"],
+ "el": ["Ισπανία"],
+ "en": ["Spain"],
+ "it": ["Spagna"],
+ "es": ["España"],
+ "et": ["Hispaania"],
+ "cs": ["Španělsko"],
+ "eu": ["Espainia"],
+ "pl": ["Hiszpania"],
+ "da": ["Spanien"],
+ "ro": ["Spania"],
+ "nl": ["Spanje"]
+ },
+ "altLabel": {
+ "de": ["Königreich Spanien", "ES", "ESP"],
+ "sv": ["España"],
+ "ru": ["Королевство Испания", "Эспанья"],
+ "pt": ["Reino de Espanha", "Reino da Espanha"],
+ "bg": ["Кралство Испания"],
+ "mt": ["Renju ta’ Spanja"],
+ "el": ["Βασίλειο της Ισπανίας"],
+ "en": ["Kingdom of Spain", "ES", "ESP"],
+ "it": ["Regno di Spagna"],
+ "fr": ["Royaume d'Espagne", "État espagnol", "ES", "ESP", "Esp."],
+ "es": [
+ "ES",
+ "ESP",
+ "Estado español",
+ "Reino de España (1975- )",
+ "Reino de España",
+ "Spaña"
+ ],
+ "eu": ["Espainiako Erresuma", "ES", "ESP"],
+ "cs": ["Španělské království"],
+ "sk": ["Španielske kráľovstvo"],
+ "ro": ["Regatul Spaniei"],
+ "nl": ["Koninkrijk Spanje", "ES", "ESP"],
+ "ca": ["Regne d'Espanya", "ES", "ESP", "Estat espanyol"]
+ },
+ "note": {
+ "de": ["Staat auf der Iberischen Halbinsel"],
+ "ru": ["Страна на юго-западе Европы"],
+ "fi": ["Valtio Lounais-Euroopassa"],
+ "pt": ["País europeu"],
+ "bg": ["Държава в Европа"],
+ "lv": ["Valsts Eiropā"],
+ "hr": ["Država u jugozapadnoj Europi"],
+ "fr": ["Pays d'Europe"],
+ "hu": ["Állam Délnyugat-Európában"],
+ "sk": ["Krajina v juhozápadnej Európe"],
+ "ga": ["Tír in iardheisceart na hEorpa"],
+ "ca": ["Estat d'Europa"],
+ "sv": ["Konstitutionell monarki i Sydeuropa"],
+ "mt": ["Pajjiż fl-Ewropa tal-Lbiċ"],
+ "el": ["Χώρα της νοτιοδυτικής Ευρώπης"],
+ "en": ["Country in southwestern Europe with territories in Africa"],
+ "it": [
+ "Stato dell'Europa sud-occidentale, membro dell'Unione europea"
+ ],
+ "es": ["País del suroeste de Europa"],
+ "et": ["Riik Edela-Euroopas"],
+ "cs": ["Stát v jihozápadní Evropě"],
+ "eu": ["Europako hego-mendebaldeko estatu burujabe bat"],
+ "pl": ["Państwo w Europie Południowej"],
+ "da": ["Land i Europa"],
+ "ro": ["Stat în Europa de Vest"],
+ "nl": [
+ "Land op het Iberisch Schiereiland in het zuidwesten van Europa"
+ ]
+ },
+ "latitude": 40.2,
+ "longitude": -3.5,
+ "owlSameAs": [
+ "http://www.wikidata.org/entity/Q29",
+ "http://viaf.org/viaf/133609710",
+ "https://d-nb.info/gnd/4055964-6",
+ "http://id.loc.gov/authorities/names/n79006971",
+ "http://data.bnf.fr/ark:/12148/cb118635857",
+ "http://www.idref.fr/026376296/id",
+ "http://www.idref.fr/027224406/id",
+ "http://id.ndl.go.jp/auth/ndlna/00571694",
+ "http://id.nlm.nih.gov/mesh/D013030",
+ "https://www.freebase.com/m/06mkj",
+ "https://g.co/kg/m/06mkj",
+ "http://id.nlm.nih.gov/mesh/Z01.542.846",
+ "http://libris.kb.se/resource/auth/163816",
+ "http://datos.bne.es/resource/XX109717",
+ "http://datos.bne.es/resource/XX450592",
+ "https://sws.geonames.org/2510769/",
+ "http://vocab.getty.edu/tgn/1000095",
+ "http://id.worldcat.org/fast/1204303",
+ "http://www.yso.fi/onto/yso/p105209",
+ "http://babelnet.org/rdf/s00031605n",
+ "http://nomisma.org/id/spain",
+ "http://zbw.eu/stw/descriptor/17161-5",
+ "http://vocabularies.unesco.org/thesaurus/concept923",
+ "http://lod.nl.go.kr/resource/KAB202013690",
+ "https://libris.kb.se/0xbddljj0wdngtx",
+ "http://www.yso.fi/onto/ysa/Y105209",
+ "http://dbpedia.org/resource/Spain"
+ ]
+ }
+ ],
+ "providedCHOs": [
+ {
+ "about": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0"
+ }
+ ],
+ "proxies": [
+ {
+ "about": "/proxy/europeana/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "dcDate": { "def": ["#1801", "#1801"], "zxx": ["1801"] },
+ "dcDescription": {
+ "en": [
+ "To the verse: “Copy of the original portrait of Lopez A. Quinto, 1824”"
+ ]
+ },
+ "dcIdentifier": {
+ "def": [
+ "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent0"
+ ]
+ },
+ "dcLanguage": { "def": ["spa"] },
+ "dcRights": {
+ "en": [
+ "The dissemination of descriptive information and digital images of this document has been authorized by the Cortes de Aragón exclusively for private use and for teaching and research activities. In no case is authorized its reproduction with lucrative purpose nor its distribution, public communication and transformation by any means without express and written authorization of the Cortes de Aragón. - http://creativecommons.org/-/by-nc-nd/4.0 /"
+ ]
+ },
+ "dcSubject": {
+ "en": [
+ "Fifth and Giui, Augustine, 1774-1827",
+ "Pencil drawings Conte-1853-Spain"
+ ]
+ },
+ "dcTitle": {
+ "en": ["Portrait of Augustine of Fifth and Guiu [Graphic Material]"]
+ },
+ "dcType": { "en": ["Illustrations and Photos"] },
+ "dctermsIssued": {
+ "en": ["[1st half s. XIX]"],
+ "es": ["[1ª mitad s. XIX]"]
+ },
+ "dctermsSpatial": {
+ "def": ["http://data.europeana.eu/place/83"],
+ "en": ["Spain"]
+ },
+ "dctermsTemporal": { "def": ["#1853", "#1853"], "en": ["1853"] },
+ "edmCurrentLocation": { "en": ["Cortes Aragón Library"] },
+ "proxyIn": [
+ "/aggregation/europeana/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0"
+ ],
+ "proxyFor": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "lineage": [
+ "/proxy/provider/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0"
+ ],
+ "edmType": "IMAGE",
+ "year": { "def": ["1801", "1853"] },
+ "europeanaProxy": true
+ },
+ {
+ "about": "/proxy/provider/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "dcCreator": {
+ "def": [
+ "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent3"
+ ]
+ },
+ "dcDate": { "def": ["1801"] },
+ "dcDescription": {
+ "es": [
+ "Al verso: \"Copia del retrato original de Lopez A. Quinto, 1824\""
+ ]
+ },
+ "dcFormat": { "en": ["image/jpeg"] },
+ "dcIdentifier": { "def": ["oai:fondohistorico.cortesaragon.es:2323"] },
+ "dcLanguage": { "def": ["spa"] },
+ "dcRights": {
+ "es": [
+ "La difusión de la información descriptiva y de las imágenes digitales de este documento ha sido autorizada por las Cortes de Aragón exclusivamente para uso privado y para actividades de docencia e investigación. En ningún caso se autoriza su reproducción con finalidad lucrativa ni su distribución, comunicación pública y transformación por cualquier medio sin autorización expresa y por escrito de las Cortes de Aragón. - http://creativecommons.org/licenses/by-nc-nd/4.0/"
+ ]
+ },
+ "dcSubject": {
+ "es": [
+ "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent4",
+ "https://hispana.mcu.es/lod/oai:fondohistorico.cortesaragon.es:2323#ent5"
+ ]
+ },
+ "dcTitle": {
+ "es": ["Retrato de Agustín de Quinto y Guiu [Material gráfico]"]
+ },
+ "dcType": { "es": ["Ilustraciones y Fotos"] },
+ "dctermsExtent": {
+ "es": [
+ "1 dibujo sobre papel : lápiz conté y carboncillo ; imagen de 48'5 x 36'5 cm en h. de 51'5 x 38 cm"
+ ]
+ },
+ "dctermsIssued": { "def": ["[1ª mitad s. XIX]"] },
+ "dctermsSpatial": { "es": ["España"] },
+ "dctermsTemporal": { "es": ["1853"] },
+ "edmHasType": { "es": ["Dibujos a lápiz Conte"] },
+ "edmCurrentLocation": { "es": ["Biblioteca Cortes Aragón"] },
+ "proxyIn": [
+ "/aggregation/provider/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0"
+ ],
+ "proxyFor": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0",
+ "edmType": "IMAGE",
+ "europeanaProxy": false
+ }
+ ],
+ "qualityAnnotations": [
+ {
+ "about": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0#contentTier",
+ "created": "2022-11-15T08:04:56.474594Z",
+ "target": [
+ "/aggregation/provider/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0"
+ ],
+ "body": "http://www.europeana.eu/schemas/epf/contentTier2"
+ },
+ {
+ "about": "/item/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0#metadataTier",
+ "created": "2022-11-15T08:04:56.474637Z",
+ "target": [
+ "/aggregation/provider/571/https___hispana_mcu_es_lod_oai_fondohistorico_cortesaragon_es_2323_ent0"
+ ],
+ "body": "http://www.europeana.eu/schemas/epf/metadataTierB"
+ }
+ ],
+ "timespans": [
+ {
+ "about": "http://data.europeana.eu/timespan/19",
+ "prefLabel": {
+ "de": ["19. Jahrhundert"],
+ "ru": ["XIX век"],
+ "fi": ["1800-luku"],
+ "pt": ["Século XIX"],
+ "bg": ["19 век"],
+ "lt": ["XIX amžius"],
+ "lv": ["19. gadsimts"],
+ "hr": ["19. stoljeće"],
+ "fr": ["XIXᵉ siècle"],
+ "hu": ["19. század"],
+ "sk": ["19. storočie"],
+ "sl": ["19. stoletje"],
+ "ga": ["19ú haois"],
+ "ca": ["Segle XIX"],
+ "sv": ["1800-talet"],
+ "el": ["19ος αιώνας"],
+ "en": ["19th century"],
+ "it": ["XIX secolo"],
+ "es": ["Siglo XIX"],
+ "et": ["19. sajand"],
+ "eu": ["XIX. mendea"],
+ "cs": ["19. století"],
+ "pl": ["XIX wiek"],
+ "ro": ["Secolul al XIX-lea"],
+ "da": ["19. århundrede"],
+ "nl": ["19e eeuw"]
+ },
+ "altLabel": {
+ "ru": ["19 век"],
+ "sv": [
+ "19:e århundradet",
+ "19:e seklet",
+ "1800-tal",
+ "1800-talet (århundrade)",
+ "1800-talet (sekel)"
+ ],
+ "en": [
+ "19th-century",
+ "19th-century",
+ "Nineteenth century",
+ "19. century",
+ "XIX Century"
+ ],
+ "it": [
+ "Ottocento",
+ "19° secolo",
+ "Secolo XIX",
+ "XIX Secolo",
+ "19esimo secolo",
+ "Diciannovesimo secolo",
+ "'800",
+ "Ottocento"
+ ],
+ "fr": ["19e siècle", "XIXe siècle"],
+ "da": ["1800-tallet"],
+ "ca": ["XIX", "Segle dinou", "Segle 19"],
+ "es": ["19. siglo", "Siglo 19", "Siglo diecinueve"]
+ },
+ "begin": { "def": ["1801-01-01"] },
+ "end": { "def": ["1900-01-01"] },
+ "owlSameAs": [
+ "http://www.wikidata.org/entity/Q6955",
+ "http://id.loc.gov/authorities/names/sh2002012475",
+ "http://id.loc.gov/authorities/names/sh85091984",
+ "http://id.nlm.nih.gov/mesh/D049672",
+ "https://www.freebase.com/m/08b3m",
+ "https://g.co/kg/m/08b3m",
+ "http://datos.bne.es/resource/XX4343988",
+ "http://vocab.getty.edu/aat/300404513",
+ "http://babelnet.org/rdf/s02210346n",
+ "http://dbpedia.org/resource/19th_century"
+ ]
+ },
+ {
+ "about": "#1853",
+ "prefLabel": { "zxx": ["1853"] },
+ "begin": { "def": ["1853-01-01"] },
+ "end": { "def": ["1853-12-31"] },
+ "isPartOf": { "def": ["http://data.europeana.eu/timespan/19"] },
+ "skosNotation": { "def": ["1853"] }
+ },
+ {
+ "about": "#1801",
+ "prefLabel": { "zxx": ["1801"] },
+ "begin": { "def": ["1801-01-01"] },
+ "end": { "def": ["1801-12-31"] },
+ "isPartOf": { "def": ["http://data.europeana.eu/timespan/19"] },
+ "skosNotation": { "def": ["1801"] }
+ }
+ ],
+ "timestamp_created": "2022-11-15T08:03:55.974Z",
+ "timestamp_created_epoch": 1668499435974,
+ "timestamp_update": "2022-11-15T08:03:55.974Z",
+ "timestamp_update_epoch": 1668499435974,
+ "type": "IMAGE"
+ }
+}
diff --git a/catalog/tests/dags/providers/provider_api_scripts/test_europeana.py b/catalog/tests/dags/providers/provider_api_scripts/test_europeana.py
index 270a59752..31e0d422a 100644
--- a/catalog/tests/dags/providers/provider_api_scripts/test_europeana.py
+++ b/catalog/tests/dags/providers/provider_api_scripts/test_europeana.py
@@ -1,9 +1,13 @@
+from unittest.mock import patch
+
import pytest
from catalog.tests.dags.providers.provider_api_scripts.resources.json_load import (
make_resource_json_func,
)
from common.licenses import LicenseInfo, get_license_info
+from common.loader import provider_details as prov
+from common.storage.image import ImageStore
from providers.provider_api_scripts.europeana import (
EuropeanaDataIngester,
EuropeanaRecordBuilder,
@@ -100,13 +104,79 @@ def test_get_batch_data_gets_items_property(ingester):
def test_get_image_list_with_realistic_response(ingester):
- response_json = _get_resource_json("europeana_example.json")
- record_count = ingester.process_batch(response_json["items"])
- assert record_count == len(response_json["items"])
+ image_store = ImageStore(provider=prov.EUROPEANA_DEFAULT_PROVIDER)
+ ingester.media_stores = {"image": image_store}
+ batch_json = _get_resource_json("europeana_example.json")
+ object_json = {}
+ with patch.object(
+ ingester, "_get_additional_item_data", return_value=object_json
+ ) as item_call:
+ with patch.object(image_store, "add_item"):
+ record_count = ingester.process_batch(batch_json["items"])
+ assert item_call.call_count == len(batch_json["items"])
+ assert record_count == len(batch_json["items"])
+
+
+ITEM_HAPPY_RESPONSE = _get_resource_json("item_full.json")
+ITEM_NOT_1ST_RESPONSE = _get_resource_json("item_not_first_webresource.json")
+ITEM_HAPPY_WEBRESOURCE = (
+ ITEM_HAPPY_RESPONSE.get("object").get("aggregations")[0].get("webResources")[0]
+)
+ITEM_NOT_1ST_WEBRESOURCE = (
+ ITEM_NOT_1ST_RESPONSE.get("object").get("aggregations")[0].get("webResources")[1]
+)
+
+
+ "response_json, url, expected",
+ [
+ pytest.param(
+ ITEM_HAPPY_RESPONSE, "happy_url", ITEM_HAPPY_WEBRESOURCE, id="happy_path"
+ ),
+ pytest.param(
+ ITEM_NOT_1ST_RESPONSE, "happy_url", ITEM_NOT_1ST_WEBRESOURCE, id="not_first"
+ ),
+ pytest.param(
+ {"success": False, "object": {}}, "happy_url", {}, id="success_is_false"
+ ),
+ pytest.param(
+ {"success": True, "no": "object"}, "happy_url", {}, id="no_object"
+ ),
+ pytest.param(
+ {"success": True, "object": {}}, "happy_url", {}, id="no_aggregation"
+ ),
+ pytest.param(None, "happy_url", {}, id="no_response"),
+ pytest.param(ITEM_HAPPY_RESPONSE, "sad_url", {}, id="wrong_url"),
+ ],
+)
+def test_get_additional_item_data(response_json, url, expected, ingester):
+ with patch.object(
+ ingester, "get_response_json", return_value=response_json
+ ) as patch_api_call:
+ with patch.object(ingester, "_get_id_and_url", return_value=("/FAKE_ID", url)):
+ actual = ingester._get_additional_item_data({})
+ assert actual == expected
+ patch_api_call.assert_called_once_with(
+ endpoint="https://api.europeana.eu/record/v2/FAKE_ID.json",
+ query_params=ingester.item_params,
+ )
+
+
+def test_get_additional_item_data_no_foreign_id(ingester):
+ with patch.object(ingester, "get_response_json", return_value={}) as patch_call:
+ actual = ingester._get_additional_item_data({"info": "but not an ID"})
+ expected = {}
+ assert actual == expected
+ patch_call.assert_not_called
def test_record_builder_get_record_data(ingester, record_builder):
- image_data = _get_resource_json("image_data_example.json")
+ image_data = _get_resource_json("image_data_example.json") | {
+ "item_webresource": _get_resource_json("item_full.json")
+ .get("object")
+ .get("aggregations")[0]
+ .get("webResources")[0]
+ }
record_data = record_builder.get_record_data(image_data)
expect_meta_data = {
@@ -131,6 +201,10 @@ def test_record_builder_get_record_data(ingester, record_builder):
),
"meta_data": expect_meta_data,
"source": ingester.providers["image"],
+ "height": 480,
+ "width": 381,
+ "filesize": 36272,
+ "filetype": "jpeg",
}
@@ -180,6 +254,46 @@ def test_get_foreign_landing_url_without_edmIsShownAt(record_builder):
)
+ "item_data, expected",
+ [
+ pytest.param(
+ ITEM_HAPPY_WEBRESOURCE, {"width": 381, "height": 480}, id="happy_path"
+ ),
+ pytest.param({"no": "dimensions"}, {}, id="no_dimensions"),
+ pytest.param({"ebucoreWidth": 381}, {}, id="no_height"),
+ pytest.param({"ebucoreHeight": 480}, {}, id="no_width"),
+ ],
+)
+def test_get_image_dimensions(item_data, expected, record_builder):
+ assert record_builder._get_image_dimensions(item_data) == expected
+
+
+ "item_data, expected",
+ [
+ pytest.param(ITEM_HAPPY_WEBRESOURCE, "jpeg", id="happy_path"),
+ pytest.param({"ebucoreHasMimeType": "image-jpeg"}, "image-jpeg", id="no_slash"),
+ pytest.param({"ebucoreHasMimeType": "gibberish"}, "gibberish", id="gibberish"),
+ pytest.param({"ebucoreHasMimeType": None}, None, id="no_filetype"),
+ ],
+)
+def test_get_filetype(item_data, expected, record_builder):
+ assert record_builder._get_filetype(item_data) == expected
+
+
+ "item_data, expected",
+ [
+ pytest.param(ITEM_HAPPY_WEBRESOURCE, 36272, id="happy_path"),
+ pytest.param({"ebucoreFileByteSize": "gibberish"}, "gibberish", id="gibberish"),
+ pytest.param({"no": "filesize"}, None, id="no_filesize"),
+ ],
+)
+def test_get_filesize(item_data, expected, record_builder):
+ assert record_builder._get_filesize(item_data) == expected
+
+
def test_get_meta_data_dict(record_builder):
image_data = _get_resource_json("image_data_example.json")