From 720ed5e472137c09995b6dbfb771e28633e2d44a Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 7 Dec 2025 14:23:08 +0000 Subject: [PATCH 01/11] Implemented SHACL rules. --- .../must/12_validation_phase.ttl | 94 ++++++++++ .../should/12_validation_phase.ttl | 165 ++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl create mode 100644 rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl diff --git a/rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl new file mode 100644 index 00000000..43293f09 --- /dev/null +++ b/rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl @@ -0,0 +1,94 @@ +# Copyright (c) 2025 eScience Lab, The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix five-safes-crate: . +@prefix rdf: . +@prefix schema: . +@prefix purl: . +@prefix sh: . +@prefix validator: . +@prefix xsd: . + + +five-safes-crate:ValidationCheckObjectHasDescriptiveNameAndIsAssessAction + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + sh:path rdf:type ; + sh:minCount 1 ; + sh:hasValue schema:AssessAction; + sh:severity sh:Violation ; + sh:message "ValidationCheck MUST be a `schema:AssessAction`." ; + ] ; + + sh:property [ + sh:a sh:PropertyShape ; + sh:name "name" ; + sh:description "ValidationCheck MUST have a human readable name string of at least 10 characters." ; + sh:path schema:name ; + sh:datatype xsd:string ; + sh:minLength 20 ; + sh:severity sh:Violation ; + sh:message "ValidationCheck MUST have a human readable name string of at least 10 characters." ; + ] . + + +five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck ; + schema:actionStatus ?status . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "actionStatus" ; + sh:description "The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)." ; + sh:path schema:actionStatus ; + sh:in ( + "http://schema.org/PotentialActionStatus" + "http://schema.org/ActiveActionStatus" + "http://schema.org/CompletedActionStatus" + "http://schema.org/FailedActionStatus" + ) ; + sh:severity sh:Violation ; + sh:message "The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)." ; + ] . \ No newline at end of file diff --git a/rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl new file mode 100644 index 00000000..8335b4f4 --- /dev/null +++ b/rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl @@ -0,0 +1,165 @@ +# Copyright (c) 2025 eScience Lab, The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix five-safes-crate: . +@prefix rdf: . +@prefix schema: . +@prefix purl: . +@prefix sh: . +@prefix validator: . +@prefix xsd: . + + +five-safes-crate:ValidationCheckShouldHaveActionStatus + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:minCount 1 ; + sh:name "actionStatus" ; + sh:description "ValidationCheck SHOULD have the `actionStatus` property." ; + sh:path schema:actionStatus ; + sh:in ( + "http://schema.org/PotentialActionStatus" + "http://schema.org/ActiveActionStatus" + "http://schema.org/CompletedActionStatus" + "http://schema.org/FailedActionStatus" + ) ; + sh:severity sh:Warning ; + sh:message "ValidationCheck SHOULD have the `actionStatus` property." ; + ] . + +five-safes-crate:RootDataEntityShouldMentionValidationCheckObject + a sh:NodeShape ; + sh:name "RootDataEntity" ; + sh:targetClass ro-crate:RootDataEntity ; + sh:description "" ; + + sh:sparql [ + a sh:SPARQLConstraint ; + sh:name "mentions" ; + sh:description "RootDataEntity SHOULD mention a ValidationCheck object." ; + sh:select """ + PREFIX schema: + PREFIX shp: + SELECT $this + WHERE { + FILTER NOT EXISTS{ + $this schema:mentions ?action . + ?action schema:additionalType shp:ValidationCheck . + } + } + """ ; + sh:severity sh:Warning ; + sh:message "RootDataEntity SHOULD mention a ValidationCheck object." ; + ] . + + +five-safes-crate:ValidationCheckObjectShouldPointToRootDataEntity + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "object" ; + sh:path schema:object ; + sh:minCount 1 ; + sh:hasValue <./> ; + 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" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "instrument" ; + sh:description "" ; + sh:path schema:instrument ; + sh:minCount 1 ; + sh:nodeKind sh:IRI ; + sh:hasValue ; + sh:severity sh:Warning ; + sh:message "`ValidationCheck` --> `instrument` SHOULD point to an entity with @id https://w3id.org/5s-crate/0.4" ; + ] . + + +five-safes-crate:ValidationCheckShouldHaveActionStatus + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "ActionStatus" ; + sh:path schema:actionStatus ; + sh:minCount 1 ; + sh:severity sh:Warning ; + sh:message "ValidationCheck SHOULD have actionStatus property." ; + ] . From 22ad642ca0a0abc7f924e22ca7d17385c4fbdfbe Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 7 Dec 2025 16:46:01 +0000 Subject: [PATCH 02/11] Added tests for implemented SHACL rules. --- ...tion_phase.ttl => 13_validation_phase.ttl} | 2 +- ...tion_phase.ttl => 13_validation_phase.ttl} | 66 ++--- .../test_5src_13_validation_phase.py | 226 ++++++++++++++++++ tests/shared.py | 5 +- 4 files changed, 265 insertions(+), 34 deletions(-) rename rocrate_validator/profiles/five-safes-crate/must/{12_validation_phase.ttl => 13_validation_phase.ttl} (99%) rename rocrate_validator/profiles/five-safes-crate/should/{12_validation_phase.ttl => 13_validation_phase.ttl} (99%) create mode 100644 tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py diff --git a/rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl similarity index 99% rename from rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl rename to rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl index 43293f09..1e582607 100644 --- a/rocrate_validator/profiles/five-safes-crate/must/12_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl @@ -55,7 +55,7 @@ five-safes-crate:ValidationCheckObjectHasDescriptiveNameAndIsAssessAction sh:description "ValidationCheck MUST have a human readable name string of at least 10 characters." ; sh:path schema:name ; sh:datatype xsd:string ; - sh:minLength 20 ; + sh:minLength 10 ; sh:severity sh:Violation ; sh:message "ValidationCheck MUST have a human readable name string of at least 10 characters." ; ] . diff --git a/rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl similarity index 99% rename from rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl rename to rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl index 8335b4f4..eb8ea458 100644 --- a/rocrate_validator/profiles/five-safes-crate/should/12_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl @@ -23,38 +23,6 @@ @prefix xsd: . -five-safes-crate:ValidationCheckShouldHaveActionStatus - a sh:NodeShape ; - sh:name "ValidationCheck" ; - sh:target [ - a sh:SPARQLTarget ; - sh:select """ - PREFIX schema: - PREFIX shp: - - SELECT ?this - WHERE { - ?this schema:additionalType shp:ValidationCheck . - } - """ ; - ] ; - - sh:property [ - a sh:PropertyShape ; - sh:minCount 1 ; - sh:name "actionStatus" ; - sh:description "ValidationCheck SHOULD have the `actionStatus` property." ; - sh:path schema:actionStatus ; - sh:in ( - "http://schema.org/PotentialActionStatus" - "http://schema.org/ActiveActionStatus" - "http://schema.org/CompletedActionStatus" - "http://schema.org/FailedActionStatus" - ) ; - sh:severity sh:Warning ; - sh:message "ValidationCheck SHOULD have the `actionStatus` property." ; - ] . - five-safes-crate:RootDataEntityShouldMentionValidationCheckObject a sh:NodeShape ; sh:name "RootDataEntity" ; @@ -163,3 +131,37 @@ five-safes-crate:ValidationCheckShouldHaveActionStatus sh:severity sh:Warning ; sh:message "ValidationCheck SHOULD have actionStatus property." ; ] . + + + +five-safes-crate:ValidationCheckShouldHaveActionStatus + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:minCount 1 ; + sh:name "actionStatus" ; + sh:description "ValidationCheck SHOULD have the `actionStatus` property." ; + sh:path schema:actionStatus ; + sh:in ( + "http://schema.org/PotentialActionStatus" + "http://schema.org/ActiveActionStatus" + "http://schema.org/CompletedActionStatus" + "http://schema.org/FailedActionStatus" + ) ; + sh:severity sh:Warning ; + sh:message "ValidationCheck SHOULD have the `actionStatus` property." ; + ] . diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py new file mode 100644 index 00000000..aab49ea4 --- /dev/null +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -0,0 +1,226 @@ +# Copyright (c) 2024-2025 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from rocrate_validator.models import Severity +from tests.ro_crates import ValidROC +from tests.shared import do_entity_test, SPARQL_PREFIXES + +# set up logging +logger = logging.getLogger(__name__) + + +# ----- MUST fails tests + +# TO BE CHECKED AGAIN +def test_5src_validation_check_not_of_type_assess_action(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + ?this rdf:type schema:AssessAction . + } + INSERT { + ?this rdf:type . + } + WHERE { + ?this rdf:type schema:AssessAction ; + schema:additionalType shp:ValidationCheck . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=["ValidationCheck MUST be a `schema:AssessAction`."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_name_not_a_string(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + ?this schema:name ?name . + } + INSERT { + ?this schema:name 123 . + } + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=["ValidationCheck MUST have a human readable name string of at least 10 characters."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_name_not_long_enough(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + ?this schema:name ?name . + } + INSERT { + ?this schema:name "Short" . + } + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=["ValidationCheck MUST have a human readable name string of at least 10 characters."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_has_action_status_with_not_allowed_value(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + ?s schema:actionStatus ?o . + } + INSERT { + ?s schema:actionStatus "Not a good action status" . + } + WHERE { + ?s schema:additionalType . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=["The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +# # ----- SHOULD fails tests + +def test_5src_root_data_entity_does_not_mention_validation_check_entity(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + <./> schema:mentions ?o . + } + WHERE { + ?o schema:additionalType shp:ValidationCheck ; + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.RECOMMENDED, + expected_validation_result=False, + expected_triggered_requirements=["RootDataEntity"], + expected_triggered_issues=["RootDataEntity SHOULD mention a ValidationCheck object."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_object_does_not_point_to_root_data_entity(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + ?s schema:object <./> . + } + INSERT { + ?s schema:object "not the RootDataEntity" . + } + WHERE { + ?s schema:additionalType shp:ValidationCheck ; + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.RECOMMENDED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=["`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate"], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_instrument_does_not_point_to_5scrate_0p4(): + sparql = """ + PREFIX schema: + PREFIX shp: + PREFIX rdf: + + DELETE { + ?s schema:instrument . + } + WHERE { + ?s schema:additionalType shp:ValidationCheck ; + schema:instrument . + } + """ + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.RECOMMENDED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=[ + "`ValidationCheck` --> `instrument` SHOULD point to an entity with @id https://w3id.org/5s-crate/0.4" + ], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_Validation_check_does_not_have_action_status_property(): + sparql = (SPARQL_PREFIXES + """ + DELETE { + ?s schema:actionStatus ?o . + } + WHERE { + ?s schema:additionalType shp:ValidationCheck ; + schema:actionStatus ?o . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.RECOMMENDED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=["ValidationCheck SHOULD have actionStatus property."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) diff --git a/tests/shared.py b/tests/shared.py index 978f60e4..b82d4ade 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -34,7 +34,10 @@ T = TypeVar("T") -SPARQL_PREFIXES = """PREFIX schema: +SPARQL_PREFIXES = """ +PREFIX schema: +PREFIX shp: +PREFIX rdf: """ From 6ae103b840f2ed969f49b3e94304b325fd701ecd Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 7 Dec 2025 16:50:24 +0000 Subject: [PATCH 03/11] removed lint error --- .../five-safes-crate/test_5src_13_validation_phase.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index aab49ea4..25a9400d 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -176,11 +176,7 @@ def test_5src_validation_check_object_does_not_point_to_root_data_entity(): def test_5src_validation_check_instrument_does_not_point_to_5scrate_0p4(): - sparql = """ - PREFIX schema: - PREFIX shp: - PREFIX rdf: - + sparql = (SPARQL_PREFIXES + """ DELETE { ?s schema:instrument . } @@ -189,6 +185,7 @@ def test_5src_validation_check_instrument_does_not_point_to_5scrate_0p4(): schema:instrument . } """ + ) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, From 69e19e2cab956754ed71abecaedc40dfd98364fe Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 7 Dec 2025 16:58:29 +0000 Subject: [PATCH 04/11] removed lint issues. --- .../test_5src_13_validation_phase.py | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index 25a9400d..c2093bac 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -26,7 +26,8 @@ # TO BE CHECKED AGAIN def test_5src_validation_check_not_of_type_assess_action(): - sparql = (SPARQL_PREFIXES + """ + sparql = ( + SPARQL_PREFIXES + """ DELETE { ?this rdf:type schema:AssessAction . } @@ -62,8 +63,7 @@ def test_5src_validation_check_name_not_a_string(): WHERE { ?this schema:additionalType shp:ValidationCheck . } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, @@ -87,8 +87,7 @@ def test_5src_validation_check_name_not_long_enough(): WHERE { ?this schema:additionalType shp:ValidationCheck . } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, @@ -112,8 +111,7 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): WHERE { ?s schema:additionalType . } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, @@ -136,8 +134,7 @@ def test_5src_root_data_entity_does_not_mention_validation_check_entity(): WHERE { ?o schema:additionalType shp:ValidationCheck ; } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, @@ -161,8 +158,7 @@ def test_5src_validation_check_object_does_not_point_to_root_data_entity(): WHERE { ?s schema:additionalType shp:ValidationCheck ; } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, @@ -184,8 +180,7 @@ def test_5src_validation_check_instrument_does_not_point_to_5scrate_0p4(): ?s schema:additionalType shp:ValidationCheck ; schema:instrument . } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, @@ -209,8 +204,7 @@ def test_5src_Validation_check_does_not_have_action_status_property(): ?s schema:additionalType shp:ValidationCheck ; schema:actionStatus ?o . } - """ - ) + """) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, From 994b586d5fcc4cb7483c0fe2c7c620e36c3ceb99 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Sun, 7 Dec 2025 17:00:31 +0000 Subject: [PATCH 05/11] removed lint issues - 2. --- .../five-safes-crate/test_5src_13_validation_phase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index c2093bac..12761783 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -118,7 +118,10 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=["The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)."], + expected_triggered_issues=[( + "The `actionStatus` of ValidationCheck MUST have an allowed value " + "(see https://schema.org/ActionStatusType)." + )], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) From fd5fa44ebc7c469b3213e60695348aa14ef496df Mon Sep 17 00:00:00 2001 From: EttoreM Date: Wed, 24 Dec 2025 12:21:17 +0000 Subject: [PATCH 06/11] (i) Removed minimum length requirement for name; (ii) split rule for actionStatus into two: a SHOULD (for existance) and a MUST (for proper values) --- .../must/13_validation_phase.ttl | 40 +++++++++++++-- .../should/13_validation_phase.ttl | 51 +++++-------------- .../test_5src_13_validation_phase.py | 36 ++++++++----- tests/shared.py | 1 + 4 files changed, 71 insertions(+), 57 deletions(-) diff --git a/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl index 1e582607..04b347b2 100644 --- a/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl @@ -52,12 +52,11 @@ five-safes-crate:ValidationCheckObjectHasDescriptiveNameAndIsAssessAction sh:property [ sh:a sh:PropertyShape ; sh:name "name" ; - sh:description "ValidationCheck MUST have a human readable name string of at least 10 characters." ; + sh:description "ValidationCheck MUST have a human readable name string." ; sh:path schema:name ; sh:datatype xsd:string ; - sh:minLength 10 ; sh:severity sh:Violation ; - sh:message "ValidationCheck MUST have a human readable name string of at least 10 characters." ; + sh:message "ValidationCheck MUST have a human readable name string." ; ] . @@ -91,4 +90,37 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue ) ; sh:severity sh:Violation ; sh:message "The `actionStatus` of ValidationCheck MUST have an allowed value (see https://schema.org/ActionStatusType)." ; - ] . \ No newline at end of file + ] . + + +five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:minCount 1 ; + sh:name "actionStatus" ; + sh:description "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ; + sh:path schema:actionStatus ; + sh:in ( + "http://schema.org/PotentialActionStatus" + "http://schema.org/ActiveActionStatus" + "http://schema.org/CompletedActionStatus" + "http://schema.org/FailedActionStatus" + ) ; + sh:severity sh:Violation ; + sh:message "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ; + ] . diff --git a/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl index eb8ea458..7138b1af 100644 --- a/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl @@ -65,12 +65,19 @@ five-safes-crate:ValidationCheckObjectShouldPointToRootDataEntity """ ; ] ; - sh:property [ - a sh:PropertyShape ; + sh:sparql [ + a sh:SPARQLConstraint ; sh:name "object" ; - sh:path schema:object ; - sh:minCount 1 ; - sh:hasValue <./> ; + sh:select """ + PREFIX schema: + PREFIX rocrate: + SELECT $this + WHERE { + FILTER NOT EXISTS { + $this schema:object rocrate:RootDataEntity . + } + } + """ ; sh:severity sh:Warning ; sh:message "`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate" ; ] . @@ -131,37 +138,3 @@ five-safes-crate:ValidationCheckShouldHaveActionStatus sh:severity sh:Warning ; sh:message "ValidationCheck SHOULD have actionStatus property." ; ] . - - - -five-safes-crate:ValidationCheckShouldHaveActionStatus - a sh:NodeShape ; - sh:name "ValidationCheck" ; - sh:target [ - a sh:SPARQLTarget ; - sh:select """ - PREFIX schema: - PREFIX shp: - - SELECT ?this - WHERE { - ?this schema:additionalType shp:ValidationCheck . - } - """ ; - ] ; - - sh:property [ - a sh:PropertyShape ; - sh:minCount 1 ; - sh:name "actionStatus" ; - sh:description "ValidationCheck SHOULD have the `actionStatus` property." ; - sh:path schema:actionStatus ; - sh:in ( - "http://schema.org/PotentialActionStatus" - "http://schema.org/ActiveActionStatus" - "http://schema.org/CompletedActionStatus" - "http://schema.org/FailedActionStatus" - ) ; - sh:severity sh:Warning ; - sh:message "ValidationCheck SHOULD have the `actionStatus` property." ; - ] . diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index 12761783..f3ecc824 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -70,22 +70,22 @@ def test_5src_validation_check_name_not_a_string(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=["ValidationCheck MUST have a human readable name string of at least 10 characters."], + expected_triggered_issues=["ValidationCheck MUST have a human readable name string."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) -def test_5src_validation_check_name_not_long_enough(): +def test_5src_validation_check_has_action_status_with_not_allowed_value(): sparql = (SPARQL_PREFIXES + """ DELETE { - ?this schema:name ?name . + ?s schema:actionStatus ?o . } INSERT { - ?this schema:name "Short" . + ?s schema:actionStatus "Not a good action status" . } WHERE { - ?this schema:additionalType shp:ValidationCheck . + ?s schema:additionalType . } """) @@ -94,14 +94,18 @@ def test_5src_validation_check_name_not_long_enough(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=["ValidationCheck MUST have a human readable name string of at least 10 characters."], + expected_triggered_issues=[( + "The `actionStatus` of ValidationCheck MUST have an allowed value " + "(see https://schema.org/ActionStatusType)." + )], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) - def test_5src_validation_check_has_action_status_with_not_allowed_value(): - sparql = (SPARQL_PREFIXES + """ + sparql = ( + SPARQL_PREFIXES + + """ DELETE { ?s schema:actionStatus ?o . } @@ -109,19 +113,23 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): ?s schema:actionStatus "Not a good action status" . } WHERE { - ?s schema:additionalType . + ?s schema:additionalType shp:ValidationCheck ; + schema:actionStatus ?o . } - """) + """ + ) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=[( - "The `actionStatus` of ValidationCheck MUST have an allowed value " - "(see https://schema.org/ActionStatusType)." - )], + expected_triggered_issues=[ + ( + "The value of actionStatus MUST be one of the allowed values: " + "PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." + ) + ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/shared.py b/tests/shared.py index b82d4ade..3d6eb616 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -38,6 +38,7 @@ PREFIX schema: PREFIX shp: PREFIX rdf: +PREFIX rocrate: """ From 3417575704ad71db87d8c65740395a6e9cc04321 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Wed, 24 Dec 2025 12:23:59 +0000 Subject: [PATCH 07/11] Removed lint error. --- .../profiles/five-safes-crate/test_5src_13_validation_phase.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index f3ecc824..0f66ca8d 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -102,6 +102,7 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): rocrate_entity_mod_sparql=sparql, ) + def test_5src_validation_check_has_action_status_with_not_allowed_value(): sparql = ( SPARQL_PREFIXES From daa73f25e34e019dfe4f1d66ba19bb36e78486f9 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Wed, 24 Dec 2025 12:26:44 +0000 Subject: [PATCH 08/11] Removed duplicated test. --- .../test_5src_13_validation_phase.py | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index 0f66ca8d..b82075b9 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -76,33 +76,6 @@ def test_5src_validation_check_name_not_a_string(): ) -def test_5src_validation_check_has_action_status_with_not_allowed_value(): - sparql = (SPARQL_PREFIXES + """ - DELETE { - ?s schema:actionStatus ?o . - } - INSERT { - ?s schema:actionStatus "Not a good action status" . - } - WHERE { - ?s schema:additionalType . - } - """) - - do_entity_test( - rocrate_path=ValidROC().five_safes_crate_result, - requirement_severity=Severity.REQUIRED, - expected_validation_result=False, - expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=[( - "The `actionStatus` of ValidationCheck MUST have an allowed value " - "(see https://schema.org/ActionStatusType)." - )], - profile_identifier="five-safes-crate", - rocrate_entity_mod_sparql=sparql, - ) - - def test_5src_validation_check_has_action_status_with_not_allowed_value(): sparql = ( SPARQL_PREFIXES From 817c422efd9b6916c22b901b618ceefca6439484 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Wed, 24 Dec 2025 13:41:01 +0000 Subject: [PATCH 09/11] Added starttiMe SHACL and test. --- .../may/13_validation_phase.ttl | 57 +++++++++++++++++++ .../test_5src_13_validation_phase.py | 34 ++++++++++- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 rocrate_validator/profiles/five-safes-crate/may/13_validation_phase.ttl diff --git a/rocrate_validator/profiles/five-safes-crate/may/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/may/13_validation_phase.ttl new file mode 100644 index 00000000..b7adcb3b --- /dev/null +++ b/rocrate_validator/profiles/five-safes-crate/may/13_validation_phase.ttl @@ -0,0 +1,57 @@ +# Copyright (c) 2025 eScience Lab, The University of Manchester +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix five-safes-crate: . +@prefix rdf: . +@prefix schema: . +@prefix purl: . +@prefix sh: . +@prefix validator: . +@prefix xsd: . + + +five-safes-crate:DownloadActionMayHaveStartTimeIfBegun + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck ; + schema:actionStatus ?status . + FILTER(?status IN ( + "http://schema.org/CompletedActionStatus", + "http://schema.org/FailedActionStatus", + "http://schema.org/ActiveActionStatus" + )) + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "StartTime" ; + sh:path schema:startTime ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:severity sh:Info ; + sh:description "ValidationCheck MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ; + sh:message "ValidationCheck MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ; + ] . diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index b82075b9..b16b71a5 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -109,7 +109,7 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): ) -# # ----- SHOULD fails tests +# ----- SHOULD fails tests def test_5src_root_data_entity_does_not_mention_validation_check_entity(): sparql = (SPARQL_PREFIXES + """ @@ -200,3 +200,35 @@ def test_5src_Validation_check_does_not_have_action_status_property(): profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) + + +# ----- MAY fails tests + +def test_5src_download_action_does_not_have_start_time(): + sparql = ( + SPARQL_PREFIXES + + """ + DELETE { + ?s schema:startTime ?time . + } + WHERE { + ?s schema:additionalType shp:ValidationCheck ; + schema:startTime ?time . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.OPTIONAL, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=[ + ( + "ValidationCheck MAY have the `startTime` property if `actionStatus` " + "is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." + ) + ], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) From 5b358798f716b3fd8e2747f89e09bf68281731f5 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Wed, 24 Dec 2025 14:03:43 +0000 Subject: [PATCH 10/11] Added rules about startTime and endTime --- .../must/13_validation_phase.ttl | 56 ++++++++++ .../should/13_validation_phase.ttl | 33 ++++++ .../test_5src_13_validation_phase.py | 100 +++++++++++++++++- 3 files changed, 187 insertions(+), 2 deletions(-) diff --git a/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl index 04b347b2..cb6b4959 100644 --- a/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl @@ -124,3 +124,59 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue sh:severity sh:Violation ; sh:message "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ; ] . + + +five-safes-crate:ValidationCheckStartTimeMUSTFollowISOStandard + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "StartTime" ; + sh:minCount 0; + sh:path schema:startTime ; + sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}([.|,][0-9]+)?(Z|z|[+-][0-9]{2}:[0-9]{2})$" ; + sh:severity sh:Violation ; + sh:message "ValidationCheck --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ; + ] . + + +five-safes-crate:ValidationCheckEndTimeMUSTFollowISOStandard + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck . + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "EndTime" ; + sh:minCount 0; + sh:path schema:endTime ; + sh:pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}([.|,][0-9]+)?(Z|z|[+-][0-9]{2}:[0-9]{2})$" ; + sh:severity sh:Violation ; + sh:message "ValidationCheck --> `endTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ; + ] . \ No newline at end of file diff --git a/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl index 7138b1af..6558715f 100644 --- a/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/should/13_validation_phase.ttl @@ -138,3 +138,36 @@ five-safes-crate:ValidationCheckShouldHaveActionStatus sh:severity sh:Warning ; sh:message "ValidationCheck SHOULD have actionStatus property." ; ] . + + +five-safes-crate:DownloadActionShouldHaveEndTimeIfBegun + a sh:NodeShape ; + sh:name "ValidationCheck" ; + sh:description "" ; + sh:target [ + a sh:SPARQLTarget ; + sh:select """ + PREFIX schema: + PREFIX shp: + SELECT ?this + WHERE { + ?this schema:additionalType shp:ValidationCheck ; + schema:actionStatus ?status . + FILTER(?status IN ( + "http://schema.org/CompletedActionStatus", + "http://schema.org/FailedActionStatus" + )) + } + """ ; + ] ; + + sh:property [ + a sh:PropertyShape ; + sh:name "EndTime" ; + sh:path schema:endTime ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:severity sh:Warning ; + sh:description "ValidationCheck SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ; + sh:message "ValidationCheck SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ; + ] . diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index b16b71a5..377d8cd2 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -100,8 +100,74 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): expected_triggered_requirements=["ValidationCheck"], expected_triggered_issues=[ ( - "The value of actionStatus MUST be one of the allowed values: " - "PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." + "The value of actionStatus MUST be one of the allowed " + "values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." + ) + ], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_start_time_not_iso_standard(): + sparql = ( + SPARQL_PREFIXES + + """ + DELETE { + ?c schema:startTime ?t . + } + INSERT { + ?c schema:startTime "1st of Jan 2021" . + } + WHERE { + ?c schema:additionalType shp:ValidationCheck ; + schema:startTime ?t . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=[ + ( + "ValidationCheck --> `startTime` MUST follows the RFC 3339 standard " + "(YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." + ) + ], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + +def test_5src_validation_check_end_time_not_iso_standard(): + sparql = ( + SPARQL_PREFIXES + + """ + DELETE { + ?c schema:endTime ?t . + } + INSERT { + ?c schema:endTime "1st of Jan 2021" . + } + WHERE { + ?c schema:additionalType shp:ValidationCheck ; + schema:endTime ?t . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=[ + ( + "ValidationCheck --> `endTime` MUST follows the RFC 3339 standard " + "(YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ) ], profile_identifier="five-safes-crate", @@ -202,6 +268,36 @@ def test_5src_Validation_check_does_not_have_action_status_property(): ) +def test_5src_download_action_does_not_have_end_time(): + sparql = ( + SPARQL_PREFIXES + + """ + DELETE { + ?s schema:endTime ?time . + } + WHERE { + ?s schema:additionalType shp:ValidationCheck ; + schema:endTime ?time . + } + """ + ) + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.RECOMMENDED, + expected_validation_result=False, + expected_triggered_requirements=["ValidationCheck"], + expected_triggered_issues=[ + ( + "ValidationCheck SHOULD have the `endTime` property if `actionStatus` " + "is either CompletedActionStatus or FailedActionStatus." + ) + ], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) + + # ----- MAY fails tests def test_5src_download_action_does_not_have_start_time(): From 78bb7ab3389c542683828bdc9ac20711e1f937d3 Mon Sep 17 00:00:00 2001 From: EttoreM Date: Wed, 24 Dec 2025 22:02:27 +0000 Subject: [PATCH 11/11] Fixed test. --- .../five-safes-crate/must/13_validation_phase.ttl | 4 ++-- .../five-safes-crate/test_5src_13_validation_phase.py | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl index cb6b4959..610d0b45 100644 --- a/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/must/13_validation_phase.ttl @@ -113,7 +113,7 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue a sh:PropertyShape ; sh:minCount 1 ; sh:name "actionStatus" ; - sh:description "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ; + sh:description "actionStatus MUST be either PotentialActionStatus, ActiveActionStatus, CompletedActionStatus, or FailedActionStatus." ; sh:path schema:actionStatus ; sh:in ( "http://schema.org/PotentialActionStatus" @@ -122,7 +122,7 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue "http://schema.org/FailedActionStatus" ) ; sh:severity sh:Violation ; - sh:message "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ; + sh:message "actionStatus MUST be either PotentialActionStatus, ActiveActionStatus, CompletedActionStatus, or FailedActionStatus." ; ] . diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index 377d8cd2..6c4435cd 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -24,7 +24,6 @@ # ----- MUST fails tests -# TO BE CHECKED AGAIN def test_5src_validation_check_not_of_type_assess_action(): sparql = ( SPARQL_PREFIXES + """ @@ -83,9 +82,6 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): DELETE { ?s schema:actionStatus ?o . } - INSERT { - ?s schema:actionStatus "Not a good action status" . - } WHERE { ?s schema:additionalType shp:ValidationCheck ; schema:actionStatus ?o . @@ -99,10 +95,7 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value(): expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], expected_triggered_issues=[ - ( - "The value of actionStatus MUST be one of the allowed " - "values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." - ) + "actionStatus MUST be either PotentialActionStatus, ActiveActionStatus, CompletedActionStatus, or FailedActionStatus." ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql,