Skip to content

Commit 817c422

Browse files
committed
Added starttiMe SHACL and test.
1 parent daa73f2 commit 817c422

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) 2025 eScience Lab, The University of Manchester
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
@prefix ro: <./> .
16+
@prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> .
17+
@prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> .
18+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
19+
@prefix schema: <http://schema.org/> .
20+
@prefix purl: <http://purl.org/dc/terms/> .
21+
@prefix sh: <http://www.w3.org/ns/shacl#> .
22+
@prefix validator: <https://github.com/crs4/rocrate-validator/> .
23+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24+
25+
26+
five-safes-crate:DownloadActionMayHaveStartTimeIfBegun
27+
a sh:NodeShape ;
28+
sh:name "ValidationCheck" ;
29+
sh:description "" ;
30+
sh:target [
31+
a sh:SPARQLTarget ;
32+
sh:select """
33+
PREFIX schema: <http://schema.org/>
34+
PREFIX shp: <https://w3id.org/shp#>
35+
SELECT ?this
36+
WHERE {
37+
?this schema:additionalType shp:ValidationCheck ;
38+
schema:actionStatus ?status .
39+
FILTER(?status IN (
40+
"http://schema.org/CompletedActionStatus",
41+
"http://schema.org/FailedActionStatus",
42+
"http://schema.org/ActiveActionStatus"
43+
))
44+
}
45+
""" ;
46+
] ;
47+
48+
sh:property [
49+
a sh:PropertyShape ;
50+
sh:name "StartTime" ;
51+
sh:path schema:startTime ;
52+
sh:minCount 1 ;
53+
sh:maxCount 1 ;
54+
sh:severity sh:Info ;
55+
sh:description "ValidationCheck MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
56+
sh:message "ValidationCheck MAY have the `startTime` property if `actionStatus` is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus." ;
57+
] .

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value():
109109
)
110110

111111

112-
# # ----- SHOULD fails tests
112+
# ----- SHOULD fails tests
113113

114114
def test_5src_root_data_entity_does_not_mention_validation_check_entity():
115115
sparql = (SPARQL_PREFIXES + """
@@ -200,3 +200,35 @@ def test_5src_Validation_check_does_not_have_action_status_property():
200200
profile_identifier="five-safes-crate",
201201
rocrate_entity_mod_sparql=sparql,
202202
)
203+
204+
205+
# ----- MAY fails tests
206+
207+
def test_5src_download_action_does_not_have_start_time():
208+
sparql = (
209+
SPARQL_PREFIXES
210+
+ """
211+
DELETE {
212+
?s schema:startTime ?time .
213+
}
214+
WHERE {
215+
?s schema:additionalType shp:ValidationCheck ;
216+
schema:startTime ?time .
217+
}
218+
"""
219+
)
220+
221+
do_entity_test(
222+
rocrate_path=ValidROC().five_safes_crate_result,
223+
requirement_severity=Severity.OPTIONAL,
224+
expected_validation_result=False,
225+
expected_triggered_requirements=["ValidationCheck"],
226+
expected_triggered_issues=[
227+
(
228+
"ValidationCheck MAY have the `startTime` property if `actionStatus` "
229+
"is either ActiveActionStatus, CompletedActionStatus or FailedActionStatus."
230+
)
231+
],
232+
profile_identifier="five-safes-crate",
233+
rocrate_entity_mod_sparql=sparql,
234+
)

0 commit comments

Comments
 (0)