Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ five-safes-crate:CheckValueObjectShouldPointToRootDataEntity
sh:name "object" ;
sh:path schema:object ;
sh:minCount 1 ;
sh:hasValue ro-crate:RootDataEntity ;
Copy link
Author

@elichad elichad Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snuck through the tests as it only fails the valid crate at RECOMMENDED level - which we don't test for (same for the Validation Phase check below). It turns out to be hard to test - see crs4#135, I'm trying to put together another PR to get those tests in never mind, it's included here now

sh:class ro-crate:RootDataEntity ;
sh:severity sh:Warning ;
sh:message "`CheckValue` --> `object` SHOULD point to the root of the RO-Crate" ;
] .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,16 @@ five-safes-crate:ValidationCheckObjectShouldPointToRootDataEntity
""" ;
] ;

sh:sparql [
a sh:SPARQLConstraint ;
sh:property [
a sh:PropertyShape ;
sh:name "object" ;
sh:select """
PREFIX schema: <http://schema.org/>
PREFIX rocrate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/>
SELECT $this
WHERE {
FILTER NOT EXISTS {
$this schema:object rocrate:RootDataEntity .
}
}
""" ;
sh:path schema:object ;
sh:minCount 1 ;
sh:class ro-crate:RootDataEntity ;
sh:severity sh:Warning ;
sh:message "`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate" ;
] .


five-safes-crate:ValidationCheckInstrumentShouldPointToEntityWithSpecificId
a sh:NodeShape ;
sh:name "ValidationCheck" ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# There SHOULD be a Sign-Off Phase
five-safes-crate:SignOffPhase
a sh:NodeShape ;
sh:targetNode <./> ;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a style change really as in 5SROC the RDE should always be <./> - but the change makes it a bit more robust and aligned with the rest of our checks

sh:targetClass ro-crate:RootDataEntity ;
sh:description "Check the Sign-Off Phase" ;
sh:sparql [
sh:select """
Expand Down
52 changes: 52 additions & 0 deletions tests/integration/profiles/five-safes-crate/test_valid_5src.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
# limitations under the License.

import logging
import pytest

from rocrate_validator import services
from rocrate_validator.models import Severity
from tests.conftest import SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER
from tests.ro_crates import ValidROC
Expand All @@ -23,6 +25,20 @@
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Dynamically fetch the SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER
# required as disable_inherited_profiles_reporting does not disable Python checks from
# inherited profiles (https://github.com/crs4/rocrate-validator/issues/135)
rocrate_profile = services.get_profile("ro-crate")
if not rocrate_profile:
raise RuntimeError("Unable to load the RO-Crate profile")
check_local_data_entity_existence = rocrate_profile.get_requirement_check(
"Web-based Data Entity: resource availability"
)
assert (
check_local_data_entity_existence
), "Unable to find the requirement 'Web-based Data Entity: resource availability'"
SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER = check_local_data_entity_existence.identifier


def test_valid_five_safes_crate_request_required():
"""Test a valid Five Safes Crate representing a request."""
Expand All @@ -37,6 +53,27 @@ def test_valid_five_safes_crate_request_required():
)


@pytest.mark.xfail(
reason="""
Checks that ensure certain Five Safes actions are present currently fail for this crate,
as this crate represents an early stage of a process before those actions have happened.
"""
)
def test_valid_five_safes_crate_request_recommended():
Comment on lines +56 to +62
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't strictly need to include this test since it fails right now. But if/when we manage to implement dynamic enabling of phase-specific checks, this will eventually pass

"""Test a valid Five Safes Crate representing a request."""
do_entity_test(
ValidROC().five_safes_crate_request,
Severity.RECOMMENDED,
True,
profile_identifier="five-safes-crate",
skip_checks=[
SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER,
SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER,
],
disable_inherited_profiles_reporting=True,
)


def test_valid_five_safes_crate_result_required():
"""Test a valid Five Safes Crate representing a result."""
do_entity_test(
Expand All @@ -50,6 +87,21 @@ def test_valid_five_safes_crate_result_required():
)


def test_valid_five_safes_crate_result_recommended():
"""Test a valid Five Safes Crate representing a result."""
do_entity_test(
ValidROC().five_safes_crate_result,
Severity.RECOMMENDED,
True,
profile_identifier="five-safes-crate",
skip_checks=[
SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER,
SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER,
],
disable_inherited_profiles_reporting=True,
)


def test_valid_five_safes_crate_multiple_context():
"""Test a valid Five Safes Crate representing a result."""
do_entity_test(
Expand Down