-
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.
Add stub for croissant validation tests
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
|
||
import mlcroissant as mlc | ||
|
||
from ckan.tests.helpers import call_action | ||
from ckanext.dcat.processors import RDFSerializer | ||
from ckanext.dcat.tests.utils import get_file_contents | ||
|
||
|
||
def test_valid_output(): | ||
|
||
dataset_dict = json.loads(get_file_contents("ckan/ckan_full_dataset_croissant.json")) | ||
|
||
s = RDFSerializer(profiles=["croissant"]) | ||
|
||
s.graph_from_dataset(dataset_dict) | ||
|
||
croissant_dict = s.g.serialize(format="json-ld") | ||
|
||
try: | ||
mlc.Dataset(croissant_dict) | ||
except mlc.ValidationError as exception: | ||
raise |
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,76 @@ | ||
{ | ||
"id": "05469327-3d64-4e54-a23b-e97e0a0b9c81", | ||
"name": "test-dataset-croissant", | ||
"title": "Test Croissant dataset", | ||
"notes": "Lorem ipsum", | ||
"id_given": "my-custom-id", | ||
"is_live_dataset": true, | ||
"url": "http://example.org/ds1", | ||
"version": "1.0b", | ||
"tags": [ | ||
{ | ||
"name": "Tag 1" | ||
}, | ||
{ | ||
"name": "Tag 2" | ||
} | ||
], | ||
"created": "2024-05-01", | ||
"issued": "2024-05-02", | ||
"modified": "2024-05-05", | ||
"license": "http://creativecommons.org/licenses/by/3.0/", | ||
"structured_data_license": "http://creativecommons.org/licenses/by/3.0/", | ||
"language": [ | ||
"en", | ||
"ca", | ||
"es" | ||
], | ||
"creator": [ | ||
{ | ||
"name": "Test Creator", | ||
"email": "creator@example.org", | ||
"url": "https://example.org", | ||
"identifier": "http://example.org/creator-id", | ||
"type": "person", | ||
"id_given": "custom-creator-id" | ||
} | ||
], | ||
"publisher": [ | ||
{ | ||
"name": "Test Publisher", | ||
"email": "publisher@example.org", | ||
"url": "https://example.org", | ||
"identifier": "http://example.org/publisher-id", | ||
"type": "person", | ||
"id_given": "custom-publisher-id" | ||
} | ||
], | ||
"same_as": [ | ||
"https://some.other.catalog/dataset/123", | ||
"https://yet.another.catalog/dataset/xyz" | ||
], | ||
"cite_as": "@Article{bloggs24data, author=\"Joe Bloggs and Sally Biggs\"}", | ||
"resources": [ | ||
{ | ||
"id": "568b8ac9-8c69-4475-b35e-d7f812a63c32", | ||
"name": "Resource 1", | ||
"description": "Some description", | ||
"url": "https://example.com/data.csv", | ||
"format": "CSV", | ||
"type": "fileSet", | ||
"id_given": "my-custom-resource-id", | ||
"size": 12323, | ||
"hash": "4304cf2e751e6053c90b1804c89c0ebb758f395a", | ||
"subresources": [ | ||
{ | ||
"type": "fileObject", | ||
"id_given": "my-custom-subresource-id", | ||
"description": "Test subresource 1", | ||
"format": "CSV", | ||
"includes": "**.csv", | ||
"excludes": "**.txt" | ||
} | ||
] | ||
} | ||
] | ||
} |