Skip to content

Commit dc26c17

Browse files
authored
Merge pull request #58 from eScienceLab/tiny-tweaks
Small SHACL fixes; test RECOMMENDED checks on valid crates
2 parents e91d725 + 617ad09 commit dc26c17

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

rocrate_validator/profiles/five-safes-crate/should/12_check_phase.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ five-safes-crate:CheckValueObjectShouldPointToRootDataEntity
7070
sh:name "object" ;
7171
sh:path schema:object ;
7272
sh:minCount 1 ;
73-
sh:hasValue ro-crate:RootDataEntity ;
73+
sh:class ro-crate:RootDataEntity ;
7474
sh:severity sh:Warning ;
7575
sh:message "`CheckValue` --> `object` SHOULD point to the root of the RO-Crate" ;
7676
] .

rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,16 @@ five-safes-crate:ValidationCheckObjectShouldPointToRootDataEntity
6565
""" ;
6666
] ;
6767

68-
sh:sparql [
69-
a sh:SPARQLConstraint ;
68+
sh:property [
69+
a sh:PropertyShape ;
7070
sh:name "object" ;
71-
sh:select """
72-
PREFIX schema: <http://schema.org/>
73-
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
74-
SELECT $this
75-
WHERE {
76-
FILTER NOT EXISTS {
77-
$this schema:object rocrate:RootDataEntity .
78-
}
79-
}
80-
""" ;
71+
sh:path schema:object ;
72+
sh:minCount 1 ;
73+
sh:class ro-crate:RootDataEntity ;
8174
sh:severity sh:Warning ;
8275
sh:message "`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate" ;
8376
] .
8477

85-
8678
five-safes-crate:ValidationCheckInstrumentShouldPointToEntityWithSpecificId
8779
a sh:NodeShape ;
8880
sh:name "ValidationCheck" ;

rocrate_validator/profiles/five-safes-crate/should/4_sign_off.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# There SHOULD be a Sign-Off Phase
2727
five-safes-crate:SignOffPhase
2828
a sh:NodeShape ;
29-
sh:targetNode <./> ;
29+
sh:targetClass ro-crate:RootDataEntity ;
3030
sh:description "Check the Sign-Off Phase" ;
3131
sh:sparql [
3232
sh:select """

tests/integration/profiles/five-safes-crate/test_valid_5src.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# limitations under the License.
1515

1616
import logging
17+
import pytest
1718

19+
from rocrate_validator import services
1820
from rocrate_validator.models import Severity
1921
from tests.conftest import SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER
2022
from tests.ro_crates import ValidROC
@@ -23,6 +25,20 @@
2325
logger = logging.getLogger(__name__)
2426
logger.setLevel(logging.DEBUG)
2527

28+
# Dynamically fetch the SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER
29+
# required as disable_inherited_profiles_reporting does not disable Python checks from
30+
# inherited profiles (https://github.com/crs4/rocrate-validator/issues/135)
31+
rocrate_profile = services.get_profile("ro-crate")
32+
if not rocrate_profile:
33+
raise RuntimeError("Unable to load the RO-Crate profile")
34+
check_local_data_entity_existence = rocrate_profile.get_requirement_check(
35+
"Web-based Data Entity: resource availability"
36+
)
37+
assert (
38+
check_local_data_entity_existence
39+
), "Unable to find the requirement 'Web-based Data Entity: resource availability'"
40+
SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER = check_local_data_entity_existence.identifier
41+
2642

2743
def test_valid_five_safes_crate_request_required():
2844
"""Test a valid Five Safes Crate representing a request."""
@@ -37,6 +53,27 @@ def test_valid_five_safes_crate_request_required():
3753
)
3854

3955

56+
@pytest.mark.xfail(
57+
reason="""
58+
Checks that ensure certain Five Safes actions are present currently fail for this crate,
59+
as this crate represents an early stage of a process before those actions have happened.
60+
"""
61+
)
62+
def test_valid_five_safes_crate_request_recommended():
63+
"""Test a valid Five Safes Crate representing a request."""
64+
do_entity_test(
65+
ValidROC().five_safes_crate_request,
66+
Severity.RECOMMENDED,
67+
True,
68+
profile_identifier="five-safes-crate",
69+
skip_checks=[
70+
SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER,
71+
SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER,
72+
],
73+
disable_inherited_profiles_reporting=True,
74+
)
75+
76+
4077
def test_valid_five_safes_crate_result_required():
4178
"""Test a valid Five Safes Crate representing a result."""
4279
do_entity_test(
@@ -50,6 +87,21 @@ def test_valid_five_safes_crate_result_required():
5087
)
5188

5289

90+
def test_valid_five_safes_crate_result_recommended():
91+
"""Test a valid Five Safes Crate representing a result."""
92+
do_entity_test(
93+
ValidROC().five_safes_crate_result,
94+
Severity.RECOMMENDED,
95+
True,
96+
profile_identifier="five-safes-crate",
97+
skip_checks=[
98+
SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER,
99+
SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER,
100+
],
101+
disable_inherited_profiles_reporting=True,
102+
)
103+
104+
53105
def test_valid_five_safes_crate_multiple_context():
54106
"""Test a valid Five Safes Crate representing a result."""
55107
do_entity_test(

0 commit comments

Comments
 (0)