udata 11.0.2.dev21__py3-none-any.whl → 11.0.2.dev23__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/core/dataservices/rdf.py +4 -7
- udata/harvest/tests/test_dcat_backend.py +45 -1
- udata/static/chunks/{10.471164b2a9fe15614797.js → 10.8ca60413647062717b1e.js} +3 -3
- udata/static/chunks/{10.471164b2a9fe15614797.js.map → 10.8ca60413647062717b1e.js.map} +1 -1
- udata/static/chunks/{11.0f04e49a40a0a381bcce.js → 11.b6f741fcc366abfad9c4.js} +3 -3
- udata/static/chunks/{11.0f04e49a40a0a381bcce.js.map → 11.b6f741fcc366abfad9c4.js.map} +1 -1
- udata/static/chunks/{13.39e106d56f794ebd06a0.js → 13.2d06442dd9a05d9777b5.js} +2 -2
- udata/static/chunks/{13.39e106d56f794ebd06a0.js.map → 13.2d06442dd9a05d9777b5.js.map} +1 -1
- udata/static/chunks/{17.70cbb4a91b002338007e.js → 17.e8e4caaad5cb0cc0bacc.js} +2 -2
- udata/static/chunks/{17.70cbb4a91b002338007e.js.map → 17.e8e4caaad5cb0cc0bacc.js.map} +1 -1
- udata/static/chunks/{19.df16abde17a42033a7f8.js → 19.f03a102365af4315f9db.js} +3 -3
- udata/static/chunks/{19.df16abde17a42033a7f8.js.map → 19.f03a102365af4315f9db.js.map} +1 -1
- udata/static/chunks/{8.0f42630e6d8ff782928e.js → 8.778091d55cd8ea39af6b.js} +2 -2
- udata/static/chunks/{8.0f42630e6d8ff782928e.js.map → 8.778091d55cd8ea39af6b.js.map} +1 -1
- udata/static/chunks/{9.07515e5187f475bce828.js → 9.033d7e190ca9e226a5d0.js} +3 -3
- udata/static/chunks/{9.07515e5187f475bce828.js.map → 9.033d7e190ca9e226a5d0.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- {udata-11.0.2.dev21.dist-info → udata-11.0.2.dev23.dist-info}/METADATA +1 -1
- {udata-11.0.2.dev21.dist-info → udata-11.0.2.dev23.dist-info}/RECORD +24 -24
- {udata-11.0.2.dev21.dist-info → udata-11.0.2.dev23.dist-info}/WHEEL +0 -0
- {udata-11.0.2.dev21.dist-info → udata-11.0.2.dev23.dist-info}/entry_points.txt +0 -0
- {udata-11.0.2.dev21.dist-info → udata-11.0.2.dev23.dist-info}/licenses/LICENSE +0 -0
- {udata-11.0.2.dev21.dist-info → udata-11.0.2.dev23.dist-info}/top_level.txt +0 -0
udata/core/dataservices/rdf.py
CHANGED
|
@@ -32,7 +32,7 @@ def dataservice_from_rdf(
|
|
|
32
32
|
remote_url_prefix: str | None = None,
|
|
33
33
|
) -> Dataservice:
|
|
34
34
|
"""
|
|
35
|
-
Create or update a
|
|
35
|
+
Create or update a dataservice from a RDF/DCAT graph
|
|
36
36
|
"""
|
|
37
37
|
if node is None: # Assume first match is the only match
|
|
38
38
|
node = graph.value(predicate=RDF.type, object=DCAT.DataService)
|
|
@@ -57,7 +57,6 @@ def dataservice_from_rdf(
|
|
|
57
57
|
contact_point for role in roles for contact_point in role
|
|
58
58
|
] or dataservice.contact_points
|
|
59
59
|
|
|
60
|
-
datasets = []
|
|
61
60
|
for dataset_node in d.objects(DCAT.servesDataset):
|
|
62
61
|
id = dataset_node.value(DCT.identifier)
|
|
63
62
|
dataset = next(
|
|
@@ -71,11 +70,9 @@ def dataservice_from_rdf(
|
|
|
71
70
|
None,
|
|
72
71
|
)
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if datasets:
|
|
78
|
-
dataservice.datasets = datasets
|
|
73
|
+
# We append the dataset to the list of the current attached ones if not already attached
|
|
74
|
+
if dataset is not None and dataset not in dataservice.datasets:
|
|
75
|
+
dataservice.datasets.append(dataset)
|
|
79
76
|
|
|
80
77
|
license = rdf_value(d, DCT.license)
|
|
81
78
|
if license is not None:
|
|
@@ -8,8 +8,9 @@ from flask import current_app
|
|
|
8
8
|
from lxml import etree
|
|
9
9
|
from rdflib import Graph
|
|
10
10
|
|
|
11
|
+
from udata.core.dataservices.factories import DataserviceFactory
|
|
11
12
|
from udata.core.dataservices.models import Dataservice
|
|
12
|
-
from udata.core.dataset.factories import LicenseFactory, ResourceSchemaMockData
|
|
13
|
+
from udata.core.dataset.factories import DatasetFactory, LicenseFactory, ResourceSchemaMockData
|
|
13
14
|
from udata.core.dataset.rdf import dataset_from_rdf
|
|
14
15
|
from udata.core.organization.factories import OrganizationFactory
|
|
15
16
|
from udata.harvest.models import HarvestJob
|
|
@@ -187,6 +188,49 @@ class DcatBackendTest:
|
|
|
187
188
|
== "https://data.paris2024.org/api/explore/v2.1/console"
|
|
188
189
|
)
|
|
189
190
|
|
|
191
|
+
def test_harvest_dataservices_keep_attached_associated_datasets(self, rmock):
|
|
192
|
+
"""It should update the existing list of dataservice.datasets and not overwrite existing ones"""
|
|
193
|
+
rmock.get("https://example.com/schemas", json=ResourceSchemaMockData.get_mock_data())
|
|
194
|
+
|
|
195
|
+
filename = "bnodes.xml"
|
|
196
|
+
url = mock_dcat(rmock, filename)
|
|
197
|
+
org = OrganizationFactory()
|
|
198
|
+
source = HarvestSourceFactory(backend="dcat", url=url, organization=org)
|
|
199
|
+
|
|
200
|
+
previously_attached_dataset = DatasetFactory()
|
|
201
|
+
previously_harvested_dataset = DatasetFactory(
|
|
202
|
+
harvest={
|
|
203
|
+
"remote_id": "2",
|
|
204
|
+
"domain": source.domain,
|
|
205
|
+
"source_id": str(source.id),
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
existing_dataservice = DataserviceFactory(
|
|
209
|
+
# Two datasets are already attached, the first one NOT connected via harvesting
|
|
210
|
+
# when the second one is connected with dcat:servesDataset in harvest graph
|
|
211
|
+
datasets=[
|
|
212
|
+
previously_attached_dataset,
|
|
213
|
+
previously_harvested_dataset,
|
|
214
|
+
],
|
|
215
|
+
harvest={
|
|
216
|
+
"remote_id": "https://data.paris2024.org/api/explore/v2.1/",
|
|
217
|
+
"domain": source.domain,
|
|
218
|
+
"source_id": str(source.id),
|
|
219
|
+
},
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
actions.run(source)
|
|
223
|
+
|
|
224
|
+
existing_dataservice.reload()
|
|
225
|
+
|
|
226
|
+
assert len(Dataservice.objects) == 1
|
|
227
|
+
assert existing_dataservice.title == "Explore API v2"
|
|
228
|
+
assert (
|
|
229
|
+
len(existing_dataservice.datasets) == 2 + 1
|
|
230
|
+
) # The previsouly harvested dataset, the previously attached one and a new harvested dataset
|
|
231
|
+
assert previously_attached_dataset in existing_dataservice.datasets
|
|
232
|
+
assert previously_harvested_dataset in existing_dataservice.datasets
|
|
233
|
+
|
|
190
234
|
def test_harvest_dataservices_ignore_accessservices(self, rmock):
|
|
191
235
|
rmock.get("https://example.com/schemas", json=ResourceSchemaMockData.get_mock_data())
|
|
192
236
|
|