From bc959fbca37576eaefdd3ec136179f01516256ab Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Tue, 9 Dec 2025 11:23:23 +0000 Subject: [PATCH 1/3] publishing phase check --- .../must/16_publishing_phase.ttl | 41 ++++++++++++++++ .../test_5src_16_publishing_phase.py | 47 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 rocrate_validator/profiles/five-safes-crate/must/16_publishing_phase.ttl create mode 100644 tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py diff --git a/rocrate_validator/profiles/five-safes-crate/must/16_publishing_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/16_publishing_phase.ttl new file mode 100644 index 00000000..5a591a4e --- /dev/null +++ b/rocrate_validator/profiles/five-safes-crate/must/16_publishing_phase.ttl @@ -0,0 +1,41 @@ +# 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:AllAssessActionsMentioned + a sh:NodeShape ; + sh:name "All AssessActions are mentioned from Root Data Entity" ; + sh:description "All AssessAction entities in the crate MUST be referenced from the Root Dataset via `mentions`." ; + sh:targetClass schema:AssessAction; + + sh:property [ + a sh:PropertyShape ; + sh:name "AssessAction mentions from RDE" ; + sh:description "All AssessAction entities in the crate MUST be referenced from the Root Dataset via `mentions`." ; + sh:path [ sh:inversePath schema:mentions ] ; + sh:node ro-crate:RootDataEntity ; + sh:minCount 1 ; + sh:severity sh:Violation ; + sh:message "All AssessAction entities in the crate MUST be referenced from the Root Dataset via `mentions`." ; + ] . diff --git a/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py new file mode 100644 index 00000000..5fcfcfd6 --- /dev/null +++ b/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py @@ -0,0 +1,47 @@ +# 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 + + +def test_5src_assess_action_not_referenced_from_rde(): + sparql = SPARQL_PREFIXES + """ + DELETE { + <./> schema:mentions ?this . + } + WHERE { + ?this a schema:AssessAction . + <./> schema:mentions ?this . + } + """ + + do_entity_test( + rocrate_path=ValidROC().five_safes_crate_result, + requirement_severity=Severity.REQUIRED, + expected_validation_result=False, + expected_triggered_requirements=["All AssessActions are mentioned from Root Data Entity"], + expected_triggered_issues=["All AssessAction entities in the crate MUST be referenced from the Root Dataset via `mentions`."], + profile_identifier="five-safes-crate", + rocrate_entity_mod_sparql=sparql, + ) From cbffc65f405b2cc8a7d20be220294432d3204ffe Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Tue, 9 Dec 2025 11:23:45 +0000 Subject: [PATCH 2/3] fix sh:a -> a --- .../five-safes-crate/must/11_workflow_execution_phase.ttl | 4 ++-- .../profiles/five-safes-crate/must/8_disclosure_phase.ttl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rocrate_validator/profiles/five-safes-crate/must/11_workflow_execution_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/11_workflow_execution_phase.ttl index a132fbe1..4551da6c 100644 --- a/rocrate_validator/profiles/five-safes-crate/must/11_workflow_execution_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/must/11_workflow_execution_phase.ttl @@ -29,7 +29,7 @@ five-safes-crate:WorkflowMustHaveDescriptiveName sh:targetClass schema:CreateAction ; sh:property [ - sh:a sh:PropertyShape ; + a sh:PropertyShape ; sh:name "name" ; sh:minCount 1 ; sh:description "Workflow (CreateAction) MUST have a name string of at least 10 characters." ; @@ -93,4 +93,4 @@ five-safes-crate:WorkflowMustHaveActionStatusWithAllowedValues ) ; sh:severity sh:Violation ; sh:message "WorkflowExecution MUST have an actionStatus with an allowed value (see https://schema.org/ActionStatusType)." ; - ] . \ No newline at end of file + ] . diff --git a/rocrate_validator/profiles/five-safes-crate/must/8_disclosure_phase.ttl b/rocrate_validator/profiles/five-safes-crate/must/8_disclosure_phase.ttl index 4e8ab6fe..e371203d 100644 --- a/rocrate_validator/profiles/five-safes-crate/must/8_disclosure_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/must/8_disclosure_phase.ttl @@ -42,7 +42,7 @@ five-safes-crate:DisclosureObjectHasDescriptiveNameAndIsAssessAction ] ; sh:property [ - sh:a sh:PropertyShape ; + a sh:PropertyShape ; sh:name "AssessAction" ; sh:description "DisclosureCheck MUST be a `schema:AssessAction`." ; sh:path rdf:type ; @@ -53,7 +53,7 @@ five-safes-crate:DisclosureObjectHasDescriptiveNameAndIsAssessAction ] ; sh:property [ - sh:a sh:PropertyShape ; + a sh:PropertyShape ; sh:name "name" ; sh:description "DisclosureCheck MUST have a name string of at least 20 characters." ; sh:path schema:name ; @@ -96,4 +96,4 @@ five-safes-crate:DisclosureObjectHasActionStatus ) ; sh:severity sh:Violation ; sh:message "The value of actionStatus MUST be one of the allowed values." ; - ] . \ No newline at end of file + ] . From 497fd52abf4e8aed30cb188b18847926698fee76 Mon Sep 17 00:00:00 2001 From: Eli Chadwick Date: Tue, 9 Dec 2025 11:24:43 +0000 Subject: [PATCH 3/3] formatting --- .../test_5src_16_publishing_phase.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py index 5fcfcfd6..6ce5bc5c 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py @@ -26,7 +26,9 @@ def test_5src_assess_action_not_referenced_from_rde(): - sparql = SPARQL_PREFIXES + """ + sparql = ( + SPARQL_PREFIXES + + """ DELETE { <./> schema:mentions ?this . } @@ -35,13 +37,19 @@ def test_5src_assess_action_not_referenced_from_rde(): <./> schema:mentions ?this . } """ + ) do_entity_test( rocrate_path=ValidROC().five_safes_crate_result, requirement_severity=Severity.REQUIRED, expected_validation_result=False, - expected_triggered_requirements=["All AssessActions are mentioned from Root Data Entity"], - expected_triggered_issues=["All AssessAction entities in the crate MUST be referenced from the Root Dataset via `mentions`."], + expected_triggered_requirements=[ + "All AssessActions are mentioned from Root Data Entity" + ], + expected_triggered_issues=[ + "All AssessAction entities in the crate MUST be referenced from " + "the Root Dataset via `mentions`." + ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, )