-
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 pull request #201 from GovDataOfficial/publisher-uri-handling
Fix behavior if publisher_uri is not available
- Loading branch information
Showing
4 changed files
with
100 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,6 +409,39 @@ def test_publisher_no_uri(self): | |
assert self._triple(g, publisher, RDF.type, FOAF.Organization) | ||
assert self._triple(g, publisher, FOAF.name, extras['publisher_name']) | ||
|
||
def test_publisher_org_no_uri(self): | ||
dataset = { | ||
'id': '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6', | ||
'name': 'test-dataset', | ||
'organization': { | ||
'id': '', | ||
'name': 'publisher1', | ||
'title': 'Example Publisher from Org', | ||
}, | ||
'extras': [ | ||
{'key': 'publisher_name', 'value': 'Example Publisher'}, | ||
{'key': 'publisher_email', 'value': '[email protected]'}, | ||
{'key': 'publisher_url', 'value': 'http://example.com/publisher/home'}, | ||
{'key': 'publisher_type', 'value': 'http://purl.org/adms/publishertype/Company'}, | ||
] | ||
} | ||
extras = self._extras(dataset) | ||
|
||
s = RDFSerializer() | ||
g = s.g | ||
|
||
dataset_ref = s.graph_from_dataset(dataset) | ||
|
||
publisher = self._triple(g, dataset_ref, DCT.publisher, None)[2] | ||
assert publisher | ||
assert isinstance(publisher, BNode) | ||
|
||
assert self._triple(g, publisher, RDF.type, FOAF.Organization) | ||
assert self._triple(g, publisher, FOAF.name, extras['publisher_name']) | ||
assert self._triple(g, publisher, FOAF.mbox, extras['publisher_email']) | ||
assert self._triple(g, publisher, FOAF.homepage, URIRef(extras['publisher_url'])) | ||
assert self._triple(g, publisher, DCT.type, URIRef(extras['publisher_type'])) | ||
|
||
def test_temporal(self): | ||
dataset = { | ||
'id': '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6', | ||
|
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 |
---|---|---|
|
@@ -130,6 +130,43 @@ def test_publisher_extras(self): | |
assert self._triple(g, contact_point, SCHEMA.url, extras['publisher_url']) | ||
assert self._triple(g, contact_point, SCHEMA.contactType, 'customer service') | ||
|
||
def test_publisher_no_uri(self): | ||
dataset = { | ||
'id': '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6', | ||
'name': 'test-dataset', | ||
'organization': { | ||
'id': '', | ||
'name': 'publisher1', | ||
'title': 'Example Publisher from Org', | ||
}, | ||
'extras': [ | ||
{'key': 'publisher_name', 'value': 'Example Publisher'}, | ||
{'key': 'publisher_email', 'value': '[email protected]'}, | ||
{'key': 'publisher_url', 'value': 'http://example.com/publisher/home'}, | ||
{'key': 'publisher_type', 'value': 'http://purl.org/adms/publishertype/Company'}, | ||
] | ||
} | ||
extras = self._extras(dataset) | ||
|
||
s = RDFSerializer(profiles=['schemaorg']) | ||
g = s.g | ||
|
||
dataset_ref = s.graph_from_dataset(dataset) | ||
|
||
publisher = self._triple(g, dataset_ref, SCHEMA.publisher, None)[2] | ||
assert publisher | ||
assert isinstance(publisher, BNode) | ||
assert self._triple(g, publisher, RDF.type, SCHEMA.Organization) | ||
assert self._triple(g, publisher, SCHEMA.name, extras['publisher_name']) | ||
|
||
contact_point = self._triple(g, publisher, SCHEMA.contactPoint, None)[2] | ||
assert contact_point | ||
assert self._triple(g, contact_point, RDF.type, SCHEMA.ContactPoint) | ||
assert self._triple(g, contact_point, SCHEMA.name, extras['publisher_name']) | ||
assert self._triple(g, contact_point, SCHEMA.email, extras['publisher_email']) | ||
assert self._triple(g, contact_point, SCHEMA.url, extras['publisher_url']) | ||
assert self._triple(g, contact_point, SCHEMA.contactType, 'customer service') | ||
|
||
def test_publisher_org(self): | ||
dataset = { | ||
'id': '4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6', | ||
|
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