-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
149 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,24 @@ def test_e2e_ckan_to_dcat(self): | |
{"name": "Contact 1", "email": "[email protected]"}, | ||
{"name": "Contact 2", "email": "[email protected]"}, | ||
], | ||
# TODO: resources | ||
"resources": [ | ||
{ | ||
"name": "Resource 1", | ||
"url": "https://example.com/data.csv", | ||
"format": "CSV", | ||
"rights": "Some stament about rights", | ||
"language": ["en", "ca", "es"], | ||
"access_services": [ | ||
{ | ||
"title": "Access Service 1", | ||
"endpoint_url": [ | ||
"https://example.org/access_service/1", | ||
"https://example.org/access_service/2", | ||
], | ||
} | ||
], | ||
} | ||
], | ||
} | ||
|
||
dataset = call_action("package_create", **dataset_dict) | ||
|
@@ -64,7 +81,7 @@ def test_e2e_ckan_to_dcat(self): | |
assert dataset["conforms_to"][0] == "Standard 1" | ||
assert dataset["contact"][0]["name"] == "Contact 1" | ||
|
||
s = RDFSerializer(profiles=["euro_dcat_ap"]) | ||
s = RDFSerializer(profiles=["euro_dcat_ap_2"]) | ||
g = s.g | ||
|
||
dataset_ref = s.graph_from_dataset(dataset) | ||
|
@@ -81,17 +98,68 @@ def test_e2e_ckan_to_dcat(self): | |
|
||
# List fields | ||
# TODO helper function | ||
conforms = [t for t in g.triples((dataset_ref, DCT.conformsTo, None))] | ||
assert len(conforms) == len(dataset["conforms_to"]) | ||
for index, item in enumerate(conforms): | ||
assert str(item[2]) == dataset["conforms_to"][index] | ||
conforms_to = [ | ||
str(t[2]) for t in g.triples((dataset_ref, DCT.conformsTo, None)) | ||
] | ||
assert conforms_to == dataset["conforms_to"] | ||
|
||
# Repeating subfields | ||
|
||
contact_details = [t for t in g.triples((dataset_ref, DCAT.contactPoint, None))] | ||
|
||
assert len(contact_details) == len(dataset["contact"]) | ||
self._triple(g, contact_details[0][2], VCARD.fn, dataset_dict["contact"][0]["name"]) | ||
self._triple(g, contact_details[0][2], VCARD.hasEmail, dataset_dict["contact"][0]["email"]) | ||
self._triple(g, contact_details[1][2], VCARD.fn, dataset_dict["contact"][1]["name"]) | ||
self._triple(g, contact_details[1][2], VCARD.hasEmail, dataset_dict["contact"][1]["email"]) | ||
self._triple( | ||
g, contact_details[0][2], VCARD.fn, dataset_dict["contact"][0]["name"] | ||
) | ||
self._triple( | ||
g, | ||
contact_details[0][2], | ||
VCARD.hasEmail, | ||
dataset_dict["contact"][0]["email"], | ||
) | ||
self._triple( | ||
g, contact_details[1][2], VCARD.fn, dataset_dict["contact"][1]["name"] | ||
) | ||
self._triple( | ||
g, | ||
contact_details[1][2], | ||
VCARD.hasEmail, | ||
dataset_dict["contact"][1]["email"], | ||
) | ||
|
||
distribution_ref = self._triple(g, dataset_ref, DCAT.distribution, None)[2] | ||
|
||
# Resources: standard fields | ||
|
||
assert self._triple( | ||
g, distribution_ref, DCT.rights, dataset_dict["resources"][0]["rights"] | ||
) | ||
|
||
# Resources: list fields | ||
|
||
language = [ | ||
str(t[2]) for t in g.triples((distribution_ref, DCT.language, None)) | ||
] | ||
assert language == dataset_dict["resources"][0]["language"] | ||
|
||
# Resource: repeating subfields | ||
access_services = [ | ||
t for t in g.triples((distribution_ref, DCAT.accessService, None)) | ||
] | ||
|
||
assert len(access_services) == len(dataset["resources"][0]["access_services"]) | ||
self._triple( | ||
g, | ||
access_services[0][2], | ||
DCT.title, | ||
dataset_dict["resources"][0]["access_services"][0]["title"], | ||
) | ||
|
||
endpoint_urls = [ | ||
str(t[2]) | ||
for t in g.triples((access_services[0][2], DCAT.endpointURL, None)) | ||
] | ||
assert ( | ||
endpoint_urls | ||
== dataset_dict["resources"][0]["access_services"][0]["endpoint_url"] | ||
) |