-
Notifications
You must be signed in to change notification settings - Fork 1
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 #76 from opendata-swiss/tests/add-dcat-ap-ch-seria…
…lization-tests Tests/add dcat ap ch serialization tests
- Loading branch information
Showing
10 changed files
with
404 additions
and
265 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
from rdflib import URIRef, BNode, Literal | ||
|
||
|
||
class BaseParseTest(object): | ||
def _extras(self, dataset): | ||
extras = {} | ||
for extra in dataset.get('extras'): | ||
extras[extra['key']] = extra['value'] | ||
return extras | ||
|
||
def _get_file_contents(self, file_name): | ||
path = os.path.join(os.path.dirname(__file__), | ||
'fixtures', | ||
file_name) | ||
with open(path, 'r') as f: | ||
return f.read() | ||
|
||
|
||
class BaseSerializeTest(BaseParseTest): | ||
|
||
def _triples(self, graph, subject, predicate, _object, data_type=None): | ||
|
||
if not (isinstance(_object, URIRef) or isinstance(_object, BNode) or _object is None): | ||
if data_type: | ||
_object = Literal(_object, datatype=data_type) | ||
else: | ||
_object = Literal(_object) | ||
triples = [t for t in graph.triples((subject, predicate, _object))] | ||
return triples | ||
|
||
def _triple(self, graph, subject, predicate, _object, data_type=None): | ||
triples = self._triples(graph, subject, predicate, _object, data_type) | ||
return triples[0] if triples else None |
16 changes: 16 additions & 0 deletions
16
ckanext/dcatapchharvest/tests/fixtures/dataset-test-uri.json
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": "4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6", | ||
"name": "test-dataset", | ||
"title": "Test DCAT dataset", | ||
"uri": "https://test.example.com/dataset/foo", | ||
"version": "1.0b", | ||
"metadata_created": "2015-06-26T15:21:09.034694", | ||
"metadata_modified": "2015-06-26T15:21:09.075774", | ||
"resources": [ | ||
{ | ||
"uri": "https://test.example.com/dataset/foo/resource/fxx", | ||
"id": "5f2be71f-636c-4d3f-aac1-50830b97f853", | ||
"package_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 |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"id": "4b6fe9ca-dc77-4cec-92a4-55c6624a5bd6", | ||
"name": "test-dataset", | ||
"title": "Test DCAT dataset", | ||
"url": "http://example.com/ds1", | ||
"version": "1.0b", | ||
"issued": "2015-06-26T15:21:09.034694", | ||
"keywords": { | ||
"fr": [], | ||
"de": [ | ||
"alter", | ||
"sozialhilfe" | ||
], | ||
"en": [ | ||
"age" | ||
], | ||
"it": [] | ||
}, | ||
"groups": [ | ||
{ | ||
"display_name": { | ||
"fr": "Economie nationale", | ||
"de": "Volkswirtschaft", | ||
"en": "National economy", | ||
"it": "Economia" | ||
}, | ||
"description": { | ||
"fr": "", | ||
"de": "", | ||
"en": "some descriptiom", | ||
"it": "" | ||
}, | ||
"image_display_url": "", | ||
"title": { | ||
"fr": "Economie nationale", | ||
"de": "Volkswirtschaft", | ||
"en": "National economy", | ||
"it": "Economia" | ||
}, | ||
"id": "5389c3f2-2f64-436b-9fac-2d1fc342f7b5", | ||
"name": "national-economy" | ||
}, | ||
{ | ||
"display_name": { | ||
"fr": "Education, science", | ||
"de": "Bildung, Wissenschaft", | ||
"en": "Education and science", | ||
"it": "Formazione e scienza" | ||
}, | ||
"description": { | ||
"fr": "", | ||
"de": "", | ||
"en": "", | ||
"it": "" | ||
}, | ||
"image_display_url": "", | ||
"title": { | ||
"fr": "Education, science", | ||
"de": "Bildung, Wissenschaft", | ||
"en": "Education and science", | ||
"it": "Formazione e scienza" | ||
}, | ||
"id": "afcb4a2a-b4b0-4d7c-984a-9078e964be49", | ||
"name": "education" | ||
}, | ||
{ | ||
"display_name": { | ||
"fr": "Finances", | ||
"de": "Finanzen", | ||
"en": "Finances", | ||
"it": "Finanze" | ||
}, | ||
"description": { | ||
"fr": "", | ||
"de": "", | ||
"en": "", | ||
"it": "" | ||
}, | ||
"image_display_url": "", | ||
"title": { | ||
"fr": "Finances", | ||
"de": "Finanzen", | ||
"en": "Finances", | ||
"it": "Finanze" | ||
}, | ||
"id": "79cbe120-e9c6-4249-b934-58ca980606d7", | ||
"name": "finances" | ||
} | ||
], | ||
"description": { | ||
"fr": "", | ||
"de": "Deutsche Beschreibung", | ||
"en": "English Description", | ||
"it": "" | ||
}, | ||
"extras": [ | ||
{ | ||
"key": "alternate_identifier", | ||
"value": "[\"xyz\", \"abc\"]" | ||
}, | ||
{ | ||
"key": "identifier", | ||
"value": "26be5452-fc5c-11e7-8450-fea9aa178066" | ||
}, | ||
{ | ||
"key": "version_notes", | ||
"value": "This is a beta version" | ||
}, | ||
{ | ||
"key": "frequency", | ||
"value": "monthly" | ||
}, | ||
{ | ||
"key": "language", | ||
"value": "[\"en\"]" | ||
}, | ||
{ | ||
"key": "theme", | ||
"value": "[\"http://eurovoc.europa.eu/100142\", \"http://eurovoc.europa.eu/100152\"]" | ||
}, | ||
{ | ||
"key": "conforms_to", | ||
"value": "[\"Standard 1\", \"Standard 2\"]" | ||
}, | ||
{ | ||
"key": "access_rights", | ||
"value": "public" | ||
}, | ||
{ | ||
"key": "documentation", | ||
"value": "[\"http://dataset.info.org/doc1\", \"http://dataset.info.org/doc2\"]" | ||
}, | ||
{ | ||
"key": "provenance", | ||
"value": "Some statement about provenance" | ||
}, | ||
{ | ||
"key": "dcat_type", | ||
"value": "test-type" | ||
}, | ||
{ | ||
"key": "related_resource", | ||
"value": "[\"http://dataset.info.org/related1\", \"http://dataset.info.org/related2\"]" | ||
}, | ||
{ | ||
"key": "has_version", | ||
"value": "[\"https://data.some.org/catalog/datasets/derived-dataset-1\", \"https://data.some.org/catalog/datasets/derived-dataset-2\"]" | ||
}, | ||
{ | ||
"key": "is_version_of", | ||
"value": "[\"https://data.some.org/catalog/datasets/original-dataset\"]" | ||
}, | ||
{ | ||
"key": "source", | ||
"value": "[\"https://data.some.org/catalog/datasets/source-dataset-1\", \"https://data.some.org/catalog/datasets/source-dataset-2\"]" | ||
}, | ||
{ | ||
"key": "sample", | ||
"value": "[\"https://data.some.org/catalog/datasets/9df8df51-63db-37a8-e044-0003ba9b0d98/sample\"]" | ||
} | ||
] | ||
} |
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
12 changes: 1 addition & 11 deletions
12
...tests/test_parse_dcatap_conformant_rdf.py → ...ts/test_dcatap_ch_parse_conformant_rdf.py
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
11 changes: 1 addition & 10 deletions
11
...arvest/tests/test_parse_deprecated_rdf.py → ...ts/test_dcatap_ch_parse_deprecated_rdf.py
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
Oops, something went wrong.