Skip to content

Commit 5b35879

Browse files
committed
Added rules about startTime and endTime
1 parent 817c422 commit 5b35879

File tree

3 files changed

+187
-2
lines changed

3 files changed

+187
-2
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,59 @@ five-safes-crate:ValidationCheckActionStatusMustHaveAllowedValue
124124
sh:severity sh:Violation ;
125125
sh:message "The value of actionStatus MUST be one of the allowed values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ;
126126
] .
127+
128+
129+
five-safes-crate:ValidationCheckStartTimeMUSTFollowISOStandard
130+
a sh:NodeShape ;
131+
sh:name "ValidationCheck" ;
132+
sh:description "" ;
133+
sh:target [
134+
a sh:SPARQLTarget ;
135+
sh:select """
136+
PREFIX schema: <http://schema.org/>
137+
PREFIX shp: <https://w3id.org/shp#>
138+
139+
SELECT ?this
140+
WHERE {
141+
?this schema:additionalType shp:ValidationCheck .
142+
}
143+
""" ;
144+
] ;
145+
146+
sh:property [
147+
a sh:PropertyShape ;
148+
sh:name "StartTime" ;
149+
sh:minCount 0;
150+
sh:path schema:startTime ;
151+
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})$" ;
152+
sh:severity sh:Violation ;
153+
sh:message "ValidationCheck --> `startTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
154+
] .
155+
156+
157+
five-safes-crate:ValidationCheckEndTimeMUSTFollowISOStandard
158+
a sh:NodeShape ;
159+
sh:name "ValidationCheck" ;
160+
sh:description "" ;
161+
sh:target [
162+
a sh:SPARQLTarget ;
163+
sh:select """
164+
PREFIX schema: <http://schema.org/>
165+
PREFIX shp: <https://w3id.org/shp#>
166+
167+
SELECT ?this
168+
WHERE {
169+
?this schema:additionalType shp:ValidationCheck .
170+
}
171+
""" ;
172+
] ;
173+
174+
sh:property [
175+
a sh:PropertyShape ;
176+
sh:name "EndTime" ;
177+
sh:minCount 0;
178+
sh:path schema:endTime ;
179+
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})$" ;
180+
sh:severity sh:Violation ;
181+
sh:message "ValidationCheck --> `endTime` MUST follows the RFC 3339 standard (YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))." ;
182+
] .

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,36 @@ five-safes-crate:ValidationCheckShouldHaveActionStatus
138138
sh:severity sh:Warning ;
139139
sh:message "ValidationCheck SHOULD have actionStatus property." ;
140140
] .
141+
142+
143+
five-safes-crate:DownloadActionShouldHaveEndTimeIfBegun
144+
a sh:NodeShape ;
145+
sh:name "ValidationCheck" ;
146+
sh:description "" ;
147+
sh:target [
148+
a sh:SPARQLTarget ;
149+
sh:select """
150+
PREFIX schema: <http://schema.org/>
151+
PREFIX shp: <https://w3id.org/shp#>
152+
SELECT ?this
153+
WHERE {
154+
?this schema:additionalType shp:ValidationCheck ;
155+
schema:actionStatus ?status .
156+
FILTER(?status IN (
157+
"http://schema.org/CompletedActionStatus",
158+
"http://schema.org/FailedActionStatus"
159+
))
160+
}
161+
""" ;
162+
] ;
163+
164+
sh:property [
165+
a sh:PropertyShape ;
166+
sh:name "EndTime" ;
167+
sh:path schema:endTime ;
168+
sh:minCount 1 ;
169+
sh:maxCount 1 ;
170+
sh:severity sh:Warning ;
171+
sh:description "ValidationCheck SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ;
172+
sh:message "ValidationCheck SHOULD have the `endTime` property if `actionStatus` is either CompletedActionStatus or FailedActionStatus." ;
173+
] .

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

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,74 @@ def test_5src_validation_check_has_action_status_with_not_allowed_value():
100100
expected_triggered_requirements=["ValidationCheck"],
101101
expected_triggered_issues=[
102102
(
103-
"The value of actionStatus MUST be one of the allowed values: "
104-
"PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus."
103+
"The value of actionStatus MUST be one of the allowed "
104+
"values: PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus."
105+
)
106+
],
107+
profile_identifier="five-safes-crate",
108+
rocrate_entity_mod_sparql=sparql,
109+
)
110+
111+
112+
def test_5src_validation_check_start_time_not_iso_standard():
113+
sparql = (
114+
SPARQL_PREFIXES
115+
+ """
116+
DELETE {
117+
?c schema:startTime ?t .
118+
}
119+
INSERT {
120+
?c schema:startTime "1st of Jan 2021" .
121+
}
122+
WHERE {
123+
?c schema:additionalType shp:ValidationCheck ;
124+
schema:startTime ?t .
125+
}
126+
"""
127+
)
128+
129+
do_entity_test(
130+
rocrate_path=ValidROC().five_safes_crate_result,
131+
requirement_severity=Severity.REQUIRED,
132+
expected_validation_result=False,
133+
expected_triggered_requirements=["ValidationCheck"],
134+
expected_triggered_issues=[
135+
(
136+
"ValidationCheck --> `startTime` MUST follows the RFC 3339 standard "
137+
"(YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))."
138+
)
139+
],
140+
profile_identifier="five-safes-crate",
141+
rocrate_entity_mod_sparql=sparql,
142+
)
143+
144+
145+
def test_5src_validation_check_end_time_not_iso_standard():
146+
sparql = (
147+
SPARQL_PREFIXES
148+
+ """
149+
DELETE {
150+
?c schema:endTime ?t .
151+
}
152+
INSERT {
153+
?c schema:endTime "1st of Jan 2021" .
154+
}
155+
WHERE {
156+
?c schema:additionalType shp:ValidationCheck ;
157+
schema:endTime ?t .
158+
}
159+
"""
160+
)
161+
162+
do_entity_test(
163+
rocrate_path=ValidROC().five_safes_crate_result,
164+
requirement_severity=Severity.REQUIRED,
165+
expected_validation_result=False,
166+
expected_triggered_requirements=["ValidationCheck"],
167+
expected_triggered_issues=[
168+
(
169+
"ValidationCheck --> `endTime` MUST follows the RFC 3339 standard "
170+
"(YYYY-MM-DD'T'hh:mm:ss[.fraction](Z | ±hh:mm))."
105171
)
106172
],
107173
profile_identifier="five-safes-crate",
@@ -202,6 +268,36 @@ def test_5src_Validation_check_does_not_have_action_status_property():
202268
)
203269

204270

271+
def test_5src_download_action_does_not_have_end_time():
272+
sparql = (
273+
SPARQL_PREFIXES
274+
+ """
275+
DELETE {
276+
?s schema:endTime ?time .
277+
}
278+
WHERE {
279+
?s schema:additionalType shp:ValidationCheck ;
280+
schema:endTime ?time .
281+
}
282+
"""
283+
)
284+
285+
do_entity_test(
286+
rocrate_path=ValidROC().five_safes_crate_result,
287+
requirement_severity=Severity.RECOMMENDED,
288+
expected_validation_result=False,
289+
expected_triggered_requirements=["ValidationCheck"],
290+
expected_triggered_issues=[
291+
(
292+
"ValidationCheck SHOULD have the `endTime` property if `actionStatus` "
293+
"is either CompletedActionStatus or FailedActionStatus."
294+
)
295+
],
296+
profile_identifier="five-safes-crate",
297+
rocrate_entity_mod_sparql=sparql,
298+
)
299+
300+
205301
# ----- MAY fails tests
206302

207303
def test_5src_download_action_does_not_have_start_time():

0 commit comments

Comments
 (0)