-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'multiple-agents' into dcat-us-3
- Loading branch information
Showing
5 changed files
with
172 additions
and
41 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
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 |
---|---|---|
|
@@ -721,6 +721,8 @@ def test_contact_details(self): | |
|
||
contact = p._contact_details(URIRef('http://example.org'), ADMS.contactPoint) | ||
|
||
contact = contact[0] | ||
|
||
assert contact['name'] == 'Point of Contact' | ||
# mailto gets removed for storage and is added again on output | ||
assert contact['email'] == '[email protected]' | ||
|
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 |
---|---|---|
|
@@ -190,7 +190,7 @@ def test_e2e_ckan_to_dcat(self): | |
g, | ||
publisher[0][2], | ||
DCT.identifier, | ||
URIRef(dataset_dict["publisher"][0]["identifier"]) | ||
URIRef(dataset_dict["publisher"][0]["identifier"]), | ||
) | ||
|
||
creator = [t for t in g.triples((dataset_ref, DCT.creator, None))] | ||
|
@@ -221,10 +221,9 @@ def test_e2e_ckan_to_dcat(self): | |
g, | ||
creator[0][2], | ||
DCT.identifier, | ||
URIRef(dataset_dict["creator"][0]["identifier"]) | ||
URIRef(dataset_dict["creator"][0]["identifier"]), | ||
) | ||
|
||
|
||
temporal = [t for t in g.triples((dataset_ref, DCT.temporal, None))] | ||
|
||
assert len(temporal) == len(dataset["temporal_coverage"]) | ||
|
@@ -275,8 +274,8 @@ def test_e2e_ckan_to_dcat(self): | |
|
||
# Statements | ||
for item in [ | ||
('access_rights', DCT.accessRights), | ||
('provenance', DCT.provenance), | ||
("access_rights", DCT.accessRights), | ||
("provenance", DCT.provenance), | ||
]: | ||
statement = [s for s in g.objects(dataset_ref, item[1])][0] | ||
assert self._triple(g, statement, RDFS.label, dataset[item[0]]) | ||
|
@@ -402,7 +401,7 @@ def test_e2e_ckan_to_dcat(self): | |
|
||
# Resources: statements | ||
statement = [s for s in g.objects(distribution_ref, DCT.rights)][0] | ||
assert self._triple(g, statement, RDFS.label, resource['rights']) | ||
assert self._triple(g, statement, RDFS.label, resource["rights"]) | ||
|
||
def test_publisher_fallback_org(self): | ||
|
||
|
@@ -856,6 +855,116 @@ def test_statement_literal(self): | |
assert dataset["notes"] == "This is a dataset" | ||
assert dataset["access_rights"] == "Some statement" | ||
|
||
def test_multiple_contacts(self): | ||
|
||
data = """ | ||
@prefix dcat: <http://www.w3.org/ns/dcat#> . | ||
@prefix dct: <http://purl.org/dc/terms/> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . | ||
<https://example.com/dataset1> | ||
a dcat:Dataset ; | ||
dct:title "Dataset 1" ; | ||
dct:description "This is a dataset" ; | ||
dcat:contactPoint [ a vcard:Kind ; | ||
vcard:fn "Test Contact 1" ; | ||
vcard:hasEmail <mailto:[email protected]> ], | ||
[ a vcard:Kind ; | ||
vcard:fn "Test Contact 2" ; | ||
vcard:hasEmail <mailto:[email protected]> ] ; | ||
. | ||
""" | ||
|
||
p = RDFParser() | ||
|
||
p.parse(data, _format="ttl") | ||
datasets = [d for d in p.datasets()] | ||
|
||
dataset = datasets[0] | ||
assert len(dataset["contact"]) == 2 | ||
assert dataset["contact"][0]["name"] == "Test Contact 1" | ||
assert dataset["contact"][0]["email"] == "[email protected]" | ||
assert dataset["contact"][1]["name"] == "Test Contact 2" | ||
assert dataset["contact"][1]["email"] == "[email protected]" | ||
|
||
def test_multiple_publishers(self): | ||
|
||
data = """ | ||
@prefix dcat: <http://www.w3.org/ns/dcat#> . | ||
@prefix dct: <http://purl.org/dc/terms/> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix org: <http://www.w3.org/ns/org#> . | ||
@prefix skos: <http://www.w3.org/2004/02/skos/core#> . | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | ||
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . | ||
<https://example.com/dataset1> | ||
a dcat:Dataset ; | ||
dct:title "Dataset 1" ; | ||
dct:description "This is a dataset" ; | ||
dct:publisher [ a org:Organization ; | ||
skos:prefLabel "Test Publisher 1" ; | ||
vcard:hasEmail <mailto:[email protected]> ; | ||
foaf:name "Test Publisher 1" ], | ||
[ a org:Organization ; | ||
skos:prefLabel "Test Publisher 2" ; | ||
vcard:hasEmail <mailto:[email protected]> ; | ||
foaf:name "Test Publisher 2" ] ; | ||
. | ||
""" | ||
|
||
p = RDFParser() | ||
|
||
p.parse(data, _format="ttl") | ||
datasets = [d for d in p.datasets()] | ||
|
||
dataset = datasets[0] | ||
assert len(dataset["publisher"]) == 2 | ||
assert dataset["publisher"][0]["name"] == "Test Publisher 1" | ||
assert dataset["publisher"][0]["email"] == "[email protected]" | ||
assert dataset["publisher"][1]["name"] == "Test Publisher 2" | ||
assert dataset["publisher"][1]["email"] == "[email protected]" | ||
|
||
def test_multiple_creators(self): | ||
|
||
data = """ | ||
@prefix dcat: <http://www.w3.org/ns/dcat#> . | ||
@prefix dct: <http://purl.org/dc/terms/> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix org: <http://www.w3.org/ns/org#> . | ||
@prefix skos: <http://www.w3.org/2004/02/skos/core#> . | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | ||
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . | ||
<https://example.com/dataset1> | ||
a dcat:Dataset ; | ||
dct:title "Dataset 1" ; | ||
dct:description "This is a dataset" ; | ||
dct:creator [ a org:Organization ; | ||
skos:prefLabel "Test Creator 1" ; | ||
vcard:hasEmail <mailto:[email protected]> ; | ||
foaf:name "Test Creator 1" ], | ||
[ a org:Organization ; | ||
skos:prefLabel "Test Creator 2" ; | ||
vcard:hasEmail <mailto:[email protected]> ; | ||
foaf:name "Test Creator 2" ] ; | ||
. | ||
""" | ||
|
||
p = RDFParser() | ||
|
||
p.parse(data, _format="ttl") | ||
datasets = [d for d in p.datasets()] | ||
|
||
dataset = datasets[0] | ||
assert len(dataset["creator"]) == 2 | ||
assert dataset["creator"][0]["name"] == "Test Creator 1" | ||
assert dataset["creator"][0]["email"] == "[email protected]" | ||
assert dataset["creator"][1]["name"] == "Test Creator 2" | ||
assert dataset["creator"][1]["email"] == "[email protected]" | ||
|
||
|
||
@pytest.mark.usefixtures("with_plugins", "clean_db", "clean_index") | ||
@pytest.mark.ckan_config("ckan.plugins", "dcat scheming_datasets") | ||
@pytest.mark.ckan_config( | ||
|