Skip to content

Commit 6d488cc

Browse files
committed
added check for indirect path from data entities to root data entity and corresponding test
1 parent d8b9d27 commit 6d488cc

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

rocrate_validator/profiles/ro-crate/must/4_data_entity_metadata.ttl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ ro-crate:DataEntityRequiredPropertiesShape a sh:NodeShape ;
137137
sh:property
138138
[
139139
a sh:PropertyShape ;
140-
sh:path [ sh:inversePath schema_org:hasPart ] ;
141-
sh:node schema_org:Dataset ;
142-
sh:minCount 1 ;
140+
# sh:path [ sh:inversePath schema_org:hasPart ] ;
141+
# sh:node schema_org:Dataset ;
142+
# sh:minCount 1 ;
143+
sh:path [ sh:oneOrMorePath [ sh:inversePath schema_org:hasPart ] ] ;
144+
sh:qualifiedValueShape [ sh:class ro-crate:RootDataEntity ] ;
145+
sh:qualifiedMinCount 1 ;
143146
sh:name "Data Entity MUST be directly referenced" ;
144147
sh:description """Check if the Data Entity is linked, either directly or indirectly, to the `Root Data Entity` using the `hasPart` (as defined in `schema.org`) property" """ ;
145148
# sh:message "A Data Entity MUST be directly or indirectly linked to the `Root Data Entity` through the `hasPart` property" ;

tests/integration/profiles/ro-crate/test_data_entity_metadata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ def test_data_entity_must_be_directly_linked():
4848
)
4949

5050

51+
def test_data_entity_not_linked():
52+
"""Test a RO-Crate with datasets not linked to the root data entity."""
53+
do_entity_test(
54+
paths.dataset_not_linked_to_root,
55+
models.Severity.REQUIRED,
56+
False,
57+
skip_checks=[SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER]
58+
)
59+
60+
5161
def test_data_entity_must_be_indirectly_linked():
5262
"""Test a RO-Crate without a root data entity."""
5363
do_entity_test(

tests/ro_crates.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ def missing_hasPart_data_entity_reference(self) -> Path:
242242
def direct_hasPart_data_entity_reference(self) -> Path:
243243
return self.base_path / "valid_direct_hasPart_reference"
244244

245+
@property
246+
def dataset_not_linked_to_root(self) -> Path:
247+
return self.base_path / "cyclic_datasets"
248+
245249
@property
246250
def indirect_hasPart_data_entity_reference(self) -> Path:
247251
return self.base_path / "valid_indirect_hasPart_reference"

0 commit comments

Comments
 (0)