udata 10.1.4.dev34419__py2.py3-none-any.whl → 10.1.4.dev34522__py2.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/dataset/api.py CHANGED
@@ -402,7 +402,21 @@ class ResourcesAPI(API):
402
402
  def put(self, dataset):
403
403
  """Reorder resources"""
404
404
  ResourceEditPermission(dataset).test()
405
- data = {"resources": request.json}
405
+ resources = request.json
406
+ if len(dataset.resources) != len(resources):
407
+ api.abort(
408
+ 400,
409
+ f"All resources must be reordered, you provided {len(resources)} "
410
+ f"out of {len(dataset.resources)}",
411
+ )
412
+ if set(r["id"] if isinstance(r, dict) else r for r in resources) != set(
413
+ str(r.id) for r in dataset.resources
414
+ ):
415
+ api.abort(
416
+ 400,
417
+ f"Resource ids must match existing ones in dataset, ie: {set(str(r.id) for r in dataset.resources)}",
418
+ )
419
+ data = {"resources": resources}
406
420
  form = ResourcesListForm.from_json(
407
421
  data, obj=dataset, instance=dataset, meta={"csrf": False}
408
422
  )
@@ -0,0 +1,180 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rdf:RDF
3
+ xmlns:adms="http://www.w3.org/ns/adms#"
4
+ xmlns:dcat="http://www.w3.org/ns/dcat#"
5
+ xmlns:dct="http://purl.org/dc/terms/"
6
+ xmlns:foaf="http://xmlns.com/foaf/0.1/"
7
+ xmlns:hydra="http://www.w3.org/ns/hydra/core#"
8
+ xmlns:ns1="http://data.europa.eu/930/"
9
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
10
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
11
+ xmlns:skos="http://www.w3.org/2004/02/skos/core#"
12
+ xmlns:vcard="http://www.w3.org/2006/vcard/ns#"
13
+ >
14
+ <rdf:Description rdf:about="https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/">
15
+ <dct:identifier>https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/</dct:identifier>
16
+ <adms:identifier rdf:nodeID="N7cbef9d8b574438f86f859e81e04e4c0"/>
17
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Dataset"/>
18
+ <dct:title>Bureaux de vote - Vanves</dct:title>
19
+ <dct:description>La liste des 23 bureaux de vote à Vanves</dct:description>
20
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:issued>
21
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:modified>
22
+ <dcat:landingPage rdf:resource="https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"/>
23
+ <dcat:keyword>administration-finances-publiques</dcat:keyword>
24
+ <dcat:keyword>bureaux-de-vote</dcat:keyword>
25
+ <dcat:keyword>elections</dcat:keyword>
26
+ <dcat:distribution rdf:resource="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-5dd4e0b2-4d96-4f36-b73e-b78ec993703c"/>
27
+ <dcat:distribution rdf:resource="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-0f80d285-72f8-49f8-a691-1dad6bd2f6db"/>
28
+ <dcat:distribution rdf:resource="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-d78d1245-6e8e-44d8-88cd-87b1dd66034f"/>
29
+ <dcat:distribution rdf:resource="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-b18fb2bd-6c8b-47a8-84fb-cdc8e29f4f1a"/>
30
+ <ns1:distributor rdf:resource="https://www.data.gouv.fr/organizations/54884a24c751df7226a3fc16/"/>
31
+ <dct:publisher rdf:resource="https://www.data.gouv.fr/api/1/contacts/67b7c3b0e2714e0e9de260a3/"/>
32
+ <dct:creator rdf:resource="https://www.data.gouv.fr/api/1/contacts/67b7c3b0e2714e0e9de260a4/"/>
33
+ </rdf:Description>
34
+ <rdf:Description rdf:about="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-5dd4e0b2-4d96-4f36-b73e-b78ec993703c">
35
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution"/>
36
+ <dct:identifier>5dd4e0b2-4d96-4f36-b73e-b78ec993703c</dct:identifier>
37
+ <dct:title>bureau-de-vote-vanves.csv</dct:title>
38
+ <dct:description>Bureaux de vote - Vanves (csv)</dct:description>
39
+ <dcat:downloadURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/catalog/datasets/bureau-de-vote-vanves/exports/csv?use_labels=true"/>
40
+ <dcat:accessURL rdf:resource="https://www.data.gouv.fr/fr/datasets/r/5dd4e0b2-4d96-4f36-b73e-b78ec993703c"/>
41
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:issued>
42
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:modified>
43
+ <dct:rights>License Not Specified</dct:rights>
44
+ <dcat:mediaType>text/csv</dcat:mediaType>
45
+ <dct:format>csv</dct:format>
46
+ </rdf:Description>
47
+ <rdf:Description rdf:about="https://www.data.gouv.fr/api/1/organizations/54884a24c751df7226a3fc16/catalog">
48
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Catalog"/>
49
+ <rdf:type rdf:resource="http://www.w3.org/ns/hydra/core#Collection"/>
50
+ <dct:publisher rdf:resource="https://www.data.gouv.fr/organizations/54884a24c751df7226a3fc16/"/>
51
+ <dct:title>Ville de Vanves</dct:title>
52
+ <dct:description>Ville de Vanves</dct:description>
53
+ <dcat:dataset rdf:resource="https://vanves-seineouest.opendatasoft.com/explore/dataset/vfe_public_219200755_20240506/"/>
54
+ <dcat:dataset rdf:resource="https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"/>
55
+ <dcat:service rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/"/>
56
+ <hydra:totalItems rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">2</hydra:totalItems>
57
+ <hydra:view rdf:resource="https://www.data.gouv.fr/api/1/organizations/54884a24c751df7226a3fc16/catalog.rdf?page=1&amp;page_size=100"/>
58
+ </rdf:Description>
59
+ <rdf:Description rdf:about="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-d78d1245-6e8e-44d8-88cd-87b1dd66034f">
60
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution"/>
61
+ <dct:identifier>d78d1245-6e8e-44d8-88cd-87b1dd66034f</dct:identifier>
62
+ <dct:title>bureau-de-vote-vanves.geojson</dct:title>
63
+ <dct:description>Bureaux de vote - Vanves (geojson)</dct:description>
64
+ <dcat:downloadURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/catalog/datasets/bureau-de-vote-vanves/exports/geojson"/>
65
+ <dcat:accessURL rdf:resource="https://www.data.gouv.fr/fr/datasets/r/d78d1245-6e8e-44d8-88cd-87b1dd66034f"/>
66
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:issued>
67
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:modified>
68
+ <dct:rights>License Not Specified</dct:rights>
69
+ <dcat:mediaType>application/json</dcat:mediaType>
70
+ <dct:format>json</dct:format>
71
+ </rdf:Description>
72
+ <rdf:Description rdf:about="https://www.data.gouv.fr/api/1/organizations/54884a24c751df7226a3fc16/catalog.rdf?page=1&amp;page_size=100">
73
+ <rdf:type rdf:resource="http://www.w3.org/ns/hydra/core#PartialCollectionView"/>
74
+ <hydra:first rdf:resource="https://www.data.gouv.fr/api/1/organizations/54884a24c751df7226a3fc16/catalog.rdf?page=1&amp;page_size=100"/>
75
+ <hydra:last rdf:resource="https://www.data.gouv.fr/api/1/organizations/54884a24c751df7226a3fc16/catalog.rdf?page=1&amp;page_size=100"/>
76
+ </rdf:Description>
77
+ <rdf:Description rdf:about="https://www.data.gouv.fr/organizations/54884a24c751df7226a3fc16/">
78
+ <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Organization"/>
79
+ <foaf:name>Ville de Vanves</foaf:name>
80
+ <rdfs:label>Ville de Vanves</rdfs:label>
81
+ <foaf:homepage rdf:resource="http://www.vanves.fr"/>
82
+ </rdf:Description>
83
+ <rdf:Description rdf:about="https://www.data.gouv.fr/datasets/66397176ff2a31840e29304c/#resource-482677b8-379c-45a5-83ef-0361fecb4cc3">
84
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution"/>
85
+ <dct:identifier>482677b8-379c-45a5-83ef-0361fecb4cc3</dct:identifier>
86
+ <dct:title>vfe_public_219200755_20240506.json</dct:title>
87
+ <dct:description>Ville de Vanves - Part des véhicules à faibles émissions dans le renouvellement du parc (json)</dct:description>
88
+ <dcat:downloadURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/catalog/datasets/vfe_public_219200755_20240506/exports/json"/>
89
+ <dcat:accessURL rdf:resource="https://www.data.gouv.fr/fr/datasets/r/482677b8-379c-45a5-83ef-0361fecb4cc3"/>
90
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-05-06T15:15:18</dct:issued>
91
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-05-06T15:15:18</dct:modified>
92
+ <dct:rights>License Not Specified</dct:rights>
93
+ <dcat:mediaType>application/json</dcat:mediaType>
94
+ <dct:format>json</dct:format>
95
+ </rdf:Description>
96
+ <rdf:Description rdf:about="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-b18fb2bd-6c8b-47a8-84fb-cdc8e29f4f1a">
97
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution"/>
98
+ <dct:identifier>b18fb2bd-6c8b-47a8-84fb-cdc8e29f4f1a</dct:identifier>
99
+ <dct:title>bureau-de-vote-vanves.zip</dct:title>
100
+ <dct:description>Bureaux de vote - Vanves (shp)</dct:description>
101
+ <dcat:downloadURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/catalog/datasets/bureau-de-vote-vanves/exports/shp"/>
102
+ <dcat:accessURL rdf:resource="https://www.data.gouv.fr/fr/datasets/r/b18fb2bd-6c8b-47a8-84fb-cdc8e29f4f1a"/>
103
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:issued>
104
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:modified>
105
+ <dct:rights>License Not Specified</dct:rights>
106
+ <dcat:mediaType>application/zip</dcat:mediaType>
107
+ <dct:format>zip</dct:format>
108
+ </rdf:Description>
109
+ <rdf:Description rdf:about="https://www.data.gouv.fr/datasets/66397176ff2a31840e29304c/#resource-aab4d337-a617-4c18-a045-291d68787a7d">
110
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution"/>
111
+ <dct:identifier>aab4d337-a617-4c18-a045-291d68787a7d</dct:identifier>
112
+ <dct:title>vfe_public_219200755_20240506.csv</dct:title>
113
+ <dct:description>Ville de Vanves - Part des véhicules à faibles émissions dans le renouvellement du parc (csv)</dct:description>
114
+ <dcat:downloadURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/catalog/datasets/vfe_public_219200755_20240506/exports/csv?use_labels=true"/>
115
+ <dcat:accessURL rdf:resource="https://www.data.gouv.fr/fr/datasets/r/aab4d337-a617-4c18-a045-291d68787a7d"/>
116
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-05-06T15:15:18</dct:issued>
117
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-05-06T15:15:18</dct:modified>
118
+ <dct:rights>License Not Specified</dct:rights>
119
+ <dcat:mediaType>text/csv</dcat:mediaType>
120
+ <dct:format>csv</dct:format>
121
+ </rdf:Description>
122
+ <rdf:Description rdf:about="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/">
123
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#DataService"/>
124
+ <dct:identifier>https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/</dct:identifier>
125
+ <dct:title>Explore API v2 https://vanves-seineouest.opendatasoft.com</dct:title>
126
+ <dct:description></dct:description>
127
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-07-12T00:03:38.764000</dct:issued>
128
+ <dcat:endpointURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/"/>
129
+ <dcat:landingPage rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/console"/>
130
+ <dcat:endpointDescription rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/swagger.json"/>
131
+ <dcat:servesDataset rdf:resource="https://vanves-seineouest.opendatasoft.com/explore/dataset/vfe_public_219200755_20240506/"/>
132
+ <dcat:servesDataset rdf:resource="https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"/>
133
+ </rdf:Description>
134
+ <rdf:Description rdf:nodeID="N25911b8ad0604e9f8de4d7e1965eb81a">
135
+ <rdf:type rdf:resource="http://www.w3.org/ns/adms#Identifier"/>
136
+ <dct:creator>data.gouv.fr</dct:creator>
137
+ <skos:notation>https://www.data.gouv.fr/datasets/66397176ff2a31840e29304c/</skos:notation>
138
+ </rdf:Description>
139
+ <rdf:Description rdf:about="https://vanves-seineouest.opendatasoft.com/explore/dataset/vfe_public_219200755_20240506/">
140
+ <dct:identifier>https://vanves-seineouest.opendatasoft.com/explore/dataset/vfe_public_219200755_20240506/</dct:identifier>
141
+ <adms:identifier rdf:nodeID="N25911b8ad0604e9f8de4d7e1965eb81a"/>
142
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Dataset"/>
143
+ <dct:title>Ville de Vanves - Part des véhicules à faibles émissions dans le renouvellement du parc</dct:title>
144
+ <dct:description>Ville de Vanves - Part des véhicules à faibles émissions dans le renouvellement du parc</dct:description>
145
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-05-06T15:15:18</dct:issued>
146
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2024-05-06T15:15:18</dct:modified>
147
+ <dcat:landingPage rdf:resource="https://vanves-seineouest.opendatasoft.com/explore/dataset/vfe_public_219200755_20240506/"/>
148
+ <dcat:distribution rdf:resource="https://www.data.gouv.fr/datasets/66397176ff2a31840e29304c/#resource-aab4d337-a617-4c18-a045-291d68787a7d"/>
149
+ <dcat:distribution rdf:resource="https://www.data.gouv.fr/datasets/66397176ff2a31840e29304c/#resource-482677b8-379c-45a5-83ef-0361fecb4cc3"/>
150
+ <ns1:distributor rdf:resource="https://www.data.gouv.fr/organizations/54884a24c751df7226a3fc16/"/>
151
+ <dct:publisher rdf:resource="https://www.data.gouv.fr/api/1/contacts/67b7c3b0e2714e0e9de260a3/"/>
152
+ <dct:creator rdf:resource="https://www.data.gouv.fr/api/1/contacts/67b7c3b0e2714e0e9de260a4/"/>
153
+ </rdf:Description>
154
+ <rdf:Description rdf:about="https://www.data.gouv.fr/api/1/contacts/67b7c3b0e2714e0e9de260a4/">
155
+ <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Kind"/>
156
+ <vcard:fn>Vanves</vcard:fn>
157
+ </rdf:Description>
158
+ <rdf:Description rdf:about="https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/#resource-0f80d285-72f8-49f8-a691-1dad6bd2f6db">
159
+ <rdf:type rdf:resource="http://www.w3.org/ns/dcat#Distribution"/>
160
+ <dct:identifier>0f80d285-72f8-49f8-a691-1dad6bd2f6db</dct:identifier>
161
+ <dct:title>bureau-de-vote-vanves.json</dct:title>
162
+ <dct:description>Bureaux de vote - Vanves (json)</dct:description>
163
+ <dcat:downloadURL rdf:resource="https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/catalog/datasets/bureau-de-vote-vanves/exports/json"/>
164
+ <dcat:accessURL rdf:resource="https://www.data.gouv.fr/fr/datasets/r/0f80d285-72f8-49f8-a691-1dad6bd2f6db"/>
165
+ <dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:issued>
166
+ <dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-04-19T12:21:56</dct:modified>
167
+ <dct:rights>License Not Specified</dct:rights>
168
+ <dcat:mediaType>application/json</dcat:mediaType>
169
+ <dct:format>json</dct:format>
170
+ </rdf:Description>
171
+ <rdf:Description rdf:about="https://www.data.gouv.fr/api/1/contacts/67b7c3b0e2714e0e9de260a3/">
172
+ <rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Kind"/>
173
+ <vcard:fn>Vanves</vcard:fn>
174
+ </rdf:Description>
175
+ <rdf:Description rdf:nodeID="N7cbef9d8b574438f86f859e81e04e4c0">
176
+ <rdf:type rdf:resource="http://www.w3.org/ns/adms#Identifier"/>
177
+ <dct:creator>data.gouv.fr</dct:creator>
178
+ <skos:notation>https://www.data.gouv.fr/datasets/61892c9d076a4d62434a1318/</skos:notation>
179
+ </rdf:Description>
180
+ </rdf:RDF>
@@ -624,6 +624,71 @@ class DcatBackendTest:
624
624
  ) # noqa
625
625
  assert dataset.harvest.last_update.date() == date.today()
626
626
 
627
+ def test_udata_xml_catalog(self, rmock):
628
+ LicenseFactory(id="fr-lo", title="Licence ouverte / Open Licence")
629
+ url = mock_dcat(rmock, "udata.xml")
630
+ org = OrganizationFactory()
631
+ source = HarvestSourceFactory(backend="dcat", url=url, organization=org)
632
+ actions.run(source.slug)
633
+
634
+ source.reload()
635
+ job = source.get_last_job()
636
+ assert len(job.items) == 3
637
+
638
+ assert Dataset.objects.filter(organization=org).count() == 2
639
+ dataset = Dataset.objects.filter(organization=org, title="Bureaux de vote - Vanves").first()
640
+
641
+ assert dataset is not None
642
+ assert "bureaux-de-vote" in dataset.tags # support dcat:keyword
643
+ assert len(dataset.resources) == 4
644
+ assert dataset.description == "La liste des 23 bureaux de vote à Vanves"
645
+ assert dataset.harvest is not None
646
+ assert (
647
+ dataset.harvest.dct_identifier
648
+ == "https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"
649
+ )
650
+ assert (
651
+ dataset.harvest.remote_id
652
+ == "https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"
653
+ )
654
+ assert dataset.harvest.created_at.isoformat() == "2019-04-19T12:21:56"
655
+ assert dataset.harvest.modified_at.isoformat() == "2019-04-19T12:21:56"
656
+ assert (
657
+ dataset.harvest.uri
658
+ == "https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"
659
+ )
660
+ assert (
661
+ dataset.harvest.remote_url
662
+ == "https://vanves-seineouest.opendatasoft.com/explore/dataset/bureau-de-vote-vanves/"
663
+ )
664
+ assert dataset.harvest.last_update.date() == date.today()
665
+
666
+ assert Dataservice.objects(organization=org).count() == 1
667
+ service = Dataservice.objects(organization=org).first()
668
+
669
+ assert service is not None
670
+ assert len(service.datasets) == 2
671
+ assert service.title == "Explore API v2 https://vanves-seineouest.opendatasoft.com"
672
+ assert service.description == ""
673
+ assert (
674
+ service.machine_documentation_url
675
+ == "https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/swagger.json"
676
+ )
677
+ assert (
678
+ service.base_api_url == "https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/"
679
+ )
680
+ assert service.harvest is not None
681
+ assert (
682
+ service.harvest.remote_id
683
+ == "https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/"
684
+ )
685
+ assert service.harvest.created_at.isoformat() == "2024-07-12T00:03:38.764000"
686
+ assert (
687
+ service.harvest.remote_url
688
+ == "https://vanves-seineouest.opendatasoft.com/api/explore/v2.1/console"
689
+ )
690
+ assert service.harvest.last_update.date() == date.today()
691
+
627
692
  def test_user_agent_get(self, rmock):
628
693
  url = mock_dcat(rmock, "catalog.xml", path="without/extension")
629
694
  rmock.head(url, headers={"Content-Type": "application/xml; charset=utf-8"})
udata/rdf.py CHANGED
@@ -312,7 +312,12 @@ def themes_from_rdf(rdf):
312
312
  def contact_points_from_rdf(rdf, prop, role, dataset):
313
313
  for contact_point in rdf.objects(prop):
314
314
  # Read contact point information
315
- if prop == DCAT.contactPoint: # Could be split on the type of contact_point instead
315
+ if isinstance(contact_point, Literal):
316
+ log.warning(f"Found a `Literal` inside {prop}, `foaf:Agent` or `vcard:Kind` expected.")
317
+ name = contact_point.toPython()
318
+ email = None
319
+ contact_form = None
320
+ elif prop == DCAT.contactPoint: # Could be split on the type of contact_point instead
316
321
  name = rdf_value(contact_point, VCARD.fn) or ""
317
322
  email = (
318
323
  rdf_value(contact_point, VCARD.hasEmail)
@@ -1287,6 +1287,54 @@ class DatasetResourceAPITest(APITestCase):
1287
1287
  )
1288
1288
  self.assertEqual(self.dataset.last_modified, initial_last_modified)
1289
1289
 
1290
+ def test_invalid_reorder(self):
1291
+ self.dataset.resources = ResourceFactory.build_batch(3)
1292
+ self.dataset.save()
1293
+
1294
+ initial_order = [r.id for r in self.dataset.resources]
1295
+
1296
+ # Not enough resources
1297
+ wrong_order_not_enough_resources = initial_order[:2]
1298
+ response = self.put(
1299
+ url_for("api.resources", dataset=self.dataset), wrong_order_not_enough_resources
1300
+ )
1301
+ self.assertStatus(response, 400)
1302
+ self.assertEqual(
1303
+ response.json["message"], "All resources must be reordered, you provided 2 out of 3"
1304
+ )
1305
+
1306
+ # Too many resources
1307
+ wrong_order_too_many_resources = initial_order + [str(uuid4())]
1308
+ response = self.put(
1309
+ url_for("api.resources", dataset=self.dataset), wrong_order_too_many_resources
1310
+ )
1311
+ self.assertStatus(response, 400)
1312
+ self.assertEqual(
1313
+ response.json["message"], "All resources must be reordered, you provided 4 out of 3"
1314
+ )
1315
+
1316
+ # Duplicated resources
1317
+ wrong_order_duplicated_resources = [initial_order[0]] * 3
1318
+ response = self.put(
1319
+ url_for("api.resources", dataset=self.dataset), wrong_order_duplicated_resources
1320
+ )
1321
+ self.assertStatus(response, 400)
1322
+ self.assertEqual(
1323
+ response.json["message"],
1324
+ f"Resource ids must match existing ones in dataset, ie: {set(str(r.id) for r in self.dataset.resources)}",
1325
+ )
1326
+
1327
+ # Resources that don't belong to this dataset
1328
+ wrong_order_random_resources_id = [str(uuid4()) for _ in range(3)]
1329
+ response = self.put(
1330
+ url_for("api.resources", dataset=self.dataset), wrong_order_random_resources_id
1331
+ )
1332
+ self.assertStatus(response, 400)
1333
+ self.assertEqual(
1334
+ response.json["message"],
1335
+ f"Resource ids must match existing ones in dataset, ie: {set(str(r.id) for r in self.dataset.resources)}",
1336
+ )
1337
+
1290
1338
  def test_update_local(self):
1291
1339
  resource = ResourceFactory()
1292
1340
  self.dataset.resources.append(resource)
@@ -1366,17 +1414,10 @@ class DatasetResourceAPITest(APITestCase):
1366
1414
  }
1367
1415
  for id in ids
1368
1416
  ]
1369
- data.append(
1370
- {
1371
- "title": faker.sentence(),
1372
- "description": faker.text(),
1373
- "url": faker.url(),
1374
- }
1375
- )
1376
1417
  response = self.put(url_for("api.resources", dataset=self.dataset), data)
1377
1418
  self.assert200(response)
1378
1419
  self.dataset.reload()
1379
- self.assertEqual(len(self.dataset.resources), 3)
1420
+ self.assertEqual(len(self.dataset.resources), 2)
1380
1421
  for idx, id in enumerate(ids):
1381
1422
  resource = self.dataset.resources[idx]
1382
1423
  rdata = data[idx]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 10.1.4.dev34419
3
+ Version: 10.1.4.dev34522
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -141,7 +141,10 @@ It is collectively taken care of by members of the
141
141
  ## Current (in progress)
142
142
 
143
143
  - Improve datasets' API perfs (do not fetch resources from Mongo, add /api/2/datasets endpoint…) [#3279](https://github.com/opendatateam/udata/pull/3279)
144
+ - Fix harvesting literal contact points [#3288](https://github.com/opendatateam/udata/pull/3288)
144
145
  - Use YEARS_OF_INACTIVITY_BEFORE_DELETION all around in code [#3287](https://github.com/opendatateam/udata/pull/3287)
146
+ - Add a udata catalog in dcat backends to test [#3289](https://github.com/opendatateam/udata/pull/3289)
147
+ - Add safeguards in the resource reorder endpoint [#3243](https://github.com/opendatateam/udata/pull/3243)
145
148
 
146
149
  ## 10.1.3 (2025-03-14)
147
150
 
@@ -10,7 +10,7 @@ udata/errors.py,sha256=E8W7b4PH7c5B85g_nsUMt8fHqMVpDFOZFkO6wMPl6bA,117
10
10
  udata/factories.py,sha256=MoklZnU8iwNL25dm3JsoXhoQs1PQWSVYL1WvcUBtJqM,492
11
11
  udata/i18n.py,sha256=Q7UELAhKOW7DmUX8BjEMnqqhQxcR6d3ioSmj90A62cg,8992
12
12
  udata/mail.py,sha256=FMGHcDAjHvk86iDUwBmVXpx3vbAb2c-j5C3BRnh9IYQ,2670
13
- udata/rdf.py,sha256=IVwXAJ-ICpgp1Vo4QLKYWHk0MAmLNUU8LVEF0GLxFMk,18098
13
+ udata/rdf.py,sha256=JmMxwq4fFBrBZQhJ6O9_nEeYUXspPzoZGTyGUD4Nyxs,18348
14
14
  udata/routing.py,sha256=uPtBOA729unQ04MwLbZ6fZH_SWo2NzAefntz4koNyR8,7583
15
15
  udata/sentry.py,sha256=ekcxqUSqxfM98TtvCsPaOoX5i2l6PEcYt7kb4l3od-Q,3223
16
16
  udata/settings.py,sha256=Bp0eeWRD1g4CAJyytHG7T8pTtdFYeb2GgoRxFLdI1W4,19124
@@ -93,7 +93,7 @@ udata/core/dataservices/tasks.py,sha256=d2tG1l6u8-eUKUYBOgnCsQLbLmLgJXU-DOzZWhhL
93
93
  udata/core/dataset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
94
  udata/core/dataset/actions.py,sha256=mX6xox0PiMrbcAPZ3VZsI26rfM-ciYfEXxN6sqqImKA,1222
95
95
  udata/core/dataset/activities.py,sha256=v8k1jwhdx62Z2ARZq8Q-x86OWSsBK99hRloPl74OCgA,1502
96
- udata/core/dataset/api.py,sha256=Cq7IAvHXRbim3Kp4CHWizOrGdHOJzB_gIXrymSd73PU,30312
96
+ udata/core/dataset/api.py,sha256=mnOJsMcRLroKfHl3h8vvOMBrbu6KhbMU9p0cvoRDm6Y,30905
97
97
  udata/core/dataset/api_fields.py,sha256=ObM2ubDowxJZGxsyC8nDiLP7XGeT8JQbLN4YqApzxy8,17529
98
98
  udata/core/dataset/apiv2.py,sha256=yPLJvAlt9NDj8cv8LrAtpmEPci2fqyOXq7MkbSRekKs,17896
99
99
  udata/core/dataset/commands.py,sha256=__hPAk_6iHtgMnEG51ux0vbNWJHxUjXhi1ukH4hF5jY,3714
@@ -299,7 +299,7 @@ udata/harvest/tests/factories.py,sha256=Jb_RwsYogWhquG8aj2bzT3JLySq3530OmZV9cofe
299
299
  udata/harvest/tests/test_actions.py,sha256=lxwCfZIJB4-3hBVezH-lbK0xxn4m2_4UuwmKS4-e6T8,27143
300
300
  udata/harvest/tests/test_api.py,sha256=pCIoBCWZYr1IKgGARMe5fZArTsTnFQXUy5ur11vs3ho,20363
301
301
  udata/harvest/tests/test_base_backend.py,sha256=NeNp6yYOPfPpPNwO_uXWS_1gS0f0yClD1Cr2Fm90uoM,19183
302
- udata/harvest/tests/test_dcat_backend.py,sha256=MMZf6pqXO3RLwQDwJ6nwOmrj8KvxEMnuE9h5Kok5dQs,39898
302
+ udata/harvest/tests/test_dcat_backend.py,sha256=QSiA1YnWXToqh__AuYUEx3-fmtGKeGsixk1wV8yp8Dk,42758
303
303
  udata/harvest/tests/test_filters.py,sha256=2nXGnLTlM0iSOZBDBxmJp1KO3_59RXLS0vmXvEs2-KE,2468
304
304
  udata/harvest/tests/test_models.py,sha256=f9NRR2_S4oZFgF8qOumg0vv-lpnEBJbI5vNtcwFdSqM,831
305
305
  udata/harvest/tests/test_notifications.py,sha256=MMzTzkv-GXMNFeOwAi31rdTsAXyLCLOSna41zOtaJG0,816
@@ -324,6 +324,7 @@ udata/harvest/tests/dcat/paged-collection-2.jsonld,sha256=YDn6-BVGuofbhJArGriUpL
324
324
  udata/harvest/tests/dcat/partial-collection-1.jsonld,sha256=emPZGvpdaqgIVTgtmlWNm-zusKjADNe_NhNidCnT-7Y,7056
325
325
  udata/harvest/tests/dcat/partial-collection-2.jsonld,sha256=zJ1ggcs2b4IJBDJ6zKJn8w5arjJBU_EHr6qFd8tu0I8,3691
326
326
  udata/harvest/tests/dcat/sig.oreme.rdf,sha256=6F1P-hPyE8bZC-5uQTskTawRd19U0opIy9LCDwp0sd4,6315
327
+ udata/harvest/tests/dcat/udata.xml,sha256=co7tLKinEdPOwEScHUXSqSAKAFSgLElYOCI3uu50Sgo,14532
327
328
  udata/linkchecker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
328
329
  udata/linkchecker/backends.py,sha256=Xe_nWwjKsdMv7kgs3mbQDppVO4lqaJlboUxa_0nk1XM,1018
329
330
  udata/linkchecker/checker.py,sha256=LB6WSMp5yvdmfdlq2ygp7uHoYEVsK0IPk6qnmhrS4GI,2903
@@ -620,7 +621,7 @@ udata/tests/api/test_auth_api.py,sha256=OMRlY0OQt60j5N4A-N3HdWTuffOjRlFHkz5a3jJF
620
621
  udata/tests/api/test_base_api.py,sha256=2w_vz0eEuq3P3aN-ByvxGc3VZAo7XtgatFfcrzf2uEU,2244
621
622
  udata/tests/api/test_contact_points.py,sha256=X_RWD_xCfR8WchhHfKEt5mxMHY77OmTyguNKCsZftdE,5337
622
623
  udata/tests/api/test_dataservices_api.py,sha256=DAOMW1nkETWz2r3JoQ9bN8n-V72HJFr4HFmrdPvQLHo,24125
623
- udata/tests/api/test_datasets_api.py,sha256=YRjyUfhfOAXFPH9v8jvqeZv-R9clRcoDCpftgRJ17is,88400
624
+ udata/tests/api/test_datasets_api.py,sha256=RjNwOj-TiD0SaXSmIttLLJLhyBbdoucfImqTA4tBnr8,90174
624
625
  udata/tests/api/test_fields.py,sha256=OW85Z5MES5HeWOpapeem8OvR1cIcrqW-xMWpdZO4LZ8,1033
625
626
  udata/tests/api/test_follow_api.py,sha256=fccgVNfcqET221PPS3p7qzb9hpvbBBUGhV-l4UeOpyk,3352
626
627
  udata/tests/api/test_me_api.py,sha256=YPd8zmR3zwJKtpSqz8nY1nOOMyXs66INeBwyhg5D0Us,13846
@@ -719,9 +720,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=QQ66ZrgCYUIGeWFuAJApsxg3HZA_mE
719
720
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=77zeFKPGBQ6Rm9EPlOvdEM4xvNfW73nnkMvL6IJhx3M,46287
720
721
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=2oLruBkM95m7L9ynig7a74UO-FV9wpZLji9HJ70G2MU,29169
721
722
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=xH_QQlYBJMfB2Y0KPuGpca3jtxhB6xJ3WkDIQ8utbUc,53262
722
- udata-10.1.4.dev34419.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
723
- udata-10.1.4.dev34419.dist-info/METADATA,sha256=Jw6bcHEWAOUo18k_WnkiHU2plFP8oEjxavIn8JOMTPs,142601
724
- udata-10.1.4.dev34419.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
725
- udata-10.1.4.dev34419.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
726
- udata-10.1.4.dev34419.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
727
- udata-10.1.4.dev34419.dist-info/RECORD,,
723
+ udata-10.1.4.dev34522.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
724
+ udata-10.1.4.dev34522.dist-info/METADATA,sha256=svKbtoIvf_bmgw_QkCIb0Z8-CdEABdbUAflIoQ-OtJs,142909
725
+ udata-10.1.4.dev34522.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
726
+ udata-10.1.4.dev34522.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
727
+ udata-10.1.4.dev34522.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
728
+ udata-10.1.4.dev34522.dist-info/RECORD,,