Skip to content

Commit

Permalink
tests: Add tests for resource field 'documentation'
Browse files Browse the repository at this point in the history
  • Loading branch information
bellisk committed Sep 19, 2023
1 parent a409df8 commit c9fbc62
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ckanext/dcatapchharvest/tests/fixtures/1901.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<dct:identifier>346265-fr@bundesamt-fur-statistik-bfs</dct:identifier>
<dct:format>HTML</dct:format>
<dct:rights>NonCommercialAllowed-CommercialWithPermission-ReferenceRequired</dct:rights>
<foaf:page>
<foaf:Document rdf:about="https://example.com/distribution-dataset-1"/>
</foaf:page>
<foaf:page>
<foaf:Document rdf:about="https://example.com/distribution-dataset-2"/>
</foaf:page>
</dcat:Distribution>
</dcat:distribution>
<dct:language>de</dct:language>
Expand Down
14 changes: 12 additions & 2 deletions ckanext/dcatapchharvest/tests/fixtures/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,18 @@
"it": ""
},
"documentation": [
"http://dataset.info.org/doc1",
"http://dataset.info.org/doc2"
"https://example.com/distribution-dataset-1",
"https://example.com/distribution-dataset-2"
],
"resources": [
{
"id": "e2c50e70-67ad-4f86-bb1b-3f93867eadaa",
"package_id": "4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6",
"documentation": [
"https://example.com/resource-dataset-1",
"https://example.com/resource-dataset-2"
]
}
],
"extras": [
{
Expand Down
8 changes: 8 additions & 0 deletions ckanext/dcatapchharvest/tests/test_dcatap_ch_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def test_graph_from_dataset(self):
for value in values:
assert self._triple(g, dataset_ref, item[1], item[2](value))

# Resources
eq_(len([t for t in g.triples((dataset_ref, DCAT.distribution, None))]), len(dataset["resources"]))
for resource_dict in dataset.get("resources", []):
distribution = URIRef(dh.resource_uri(resource_dict))
assert self._triple(g, distribution, RDF.type, DCAT.Distribution)
for link in resource_dict.get("documentation", []):
assert self._triple(g, distribution, FOAF.page, URIRef(link))

def test_graph_from_dataset_uri(self):
"""Tests that datasets (resources) with a uri from the test system
have that uri changed to reference the prod system when they are output
Expand Down

0 comments on commit c9fbc62

Please sign in to comment.