Skip to content

Commit 8949a7a

Browse files
committed
Added the remaining python tests.
1 parent a58d89e commit 8949a7a

3 files changed

Lines changed: 164 additions & 2 deletions

File tree

rocrate_validator/profiles/five-safes-crate/should/12_check_phase.ttl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ five-safes-crate:CheckValueShouldHaveActionStatus
178178
sh:property [
179179
a sh:PropertyShape ;
180180
sh:name "ActionStatus" ;
181-
sh:description "CheckValue SHOULD have actionStatus property." ;
182181
sh:path schema:actionStatus ;
183182
sh:minCount 1 ;
184183
sh:severity sh:Warning ;

tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@
230230
},
231231
"agent": {
232232
"@id": "#validator-a4a66c63-2fe0-4c57-830d-268a40718313"
233-
}
233+
},
234+
"actionStatus": "http://schema.org/CompletedActionStatus"
234235
},
235236
{
236237
"@id": "#validate-1146f640-819e-4c86-b029-b763a0040896",

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

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,91 @@ def test_5src_check_value_name_not_long_enough():
115115

116116

117117

118+
def test_5src_check_value_start_time_not_iso_standard():
119+
sparql = """
120+
PREFIX schema: <http://schema.org/>
121+
PREFIX shp: <https://w3id.org/shp#>
122+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
123+
124+
DELETE {
125+
?c schema:startTime ?t .
126+
}
127+
INSERT {
128+
?c schema:startTime "1st of Jan 2021" .
129+
}
130+
WHERE {
131+
?c schema:additionalType shp:CheckValue ;
132+
schema:startTime ?t .
133+
}
134+
"""
135+
136+
do_entity_test(
137+
rocrate_path=ValidROC().five_safes_crate_result,
138+
requirement_severity=Severity.REQUIRED,
139+
expected_validation_result=False,
140+
expected_triggered_requirements=["CheckValue"],
141+
expected_triggered_issues=["`CheckValue` --> `startTime` MUST follows the RFC 3339 standard."],
142+
profile_identifier="five-safes-crate",
143+
rocrate_entity_mod_sparql=sparql,
144+
)
145+
146+
147+
def test_5src_check_value_end_time_not_iso_standard():
148+
sparql = """
149+
PREFIX schema: <http://schema.org/>
150+
PREFIX shp: <https://w3id.org/shp#>
151+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
152+
153+
DELETE {
154+
?c schema:endTime ?t .
155+
}
156+
INSERT {
157+
?c schema:endTime "1st of Jan 2021" .
158+
}
159+
WHERE {
160+
?c schema:additionalType shp:CheckValue ;
161+
schema:endTime ?t .
162+
}
163+
"""
164+
165+
do_entity_test(
166+
rocrate_path=ValidROC().five_safes_crate_result,
167+
requirement_severity=Severity.REQUIRED,
168+
expected_validation_result=False,
169+
expected_triggered_requirements=["CheckValue"],
170+
expected_triggered_issues=["`CheckValue` --> `endTime` MUST follows the RFC 3339 standard."],
171+
profile_identifier="five-safes-crate",
172+
rocrate_entity_mod_sparql=sparql,
173+
)
174+
175+
176+
def test_5src_check_value_has_action_status_with_not_allowed_value():
177+
sparql = """
178+
PREFIX schema: <http://schema.org/>
179+
PREFIX shp: <https://w3id.org/shp#>
180+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
181+
182+
DELETE {
183+
?s schema:actionStatus ?o .
184+
}
185+
INSERT {
186+
?s schema:actionStatus "Not a good action status" .
187+
}
188+
WHERE {
189+
?s schema:additionalType <https://w3id.org/shp#CheckValue> ;
190+
schema:actionStatus ?o .
191+
}
192+
"""
193+
194+
do_entity_test(
195+
rocrate_path=ValidROC().five_safes_crate_result,
196+
requirement_severity=Severity.REQUIRED,
197+
expected_validation_result=False,
198+
expected_triggered_requirements=["CheckValue"],
199+
expected_triggered_issues=["`CheckValue` --> `actionStatus` MUST have one of the allowed values."],
200+
profile_identifier="five-safes-crate",
201+
rocrate_entity_mod_sparql=sparql,
202+
)
118203

119204
# ----- SHOULD fails tests
120205

@@ -201,6 +286,83 @@ def test_5src_check_value_instrument_does_not_point_to_entity_with_type_defined_
201286
)
202287

203288

289+
def test_5src_check_value_does_not_have_start_time():
290+
sparql = """
291+
PREFIX schema: <http://schema.org/>
292+
PREFIX shp: <https://w3id.org/shp#>
293+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
294+
295+
DELETE {
296+
?c schema:endTime ?t .
297+
}
298+
WHERE {
299+
?c schema:additionalType shp:CheckValue ;
300+
schema:endTime ?t .
301+
}
302+
"""
303+
304+
do_entity_test(
305+
rocrate_path=ValidROC().five_safes_crate_result,
306+
requirement_severity=Severity.RECOMMENDED,
307+
expected_validation_result=False,
308+
expected_triggered_requirements=["CheckValue"],
309+
expected_triggered_issues=["`CheckValue` SHOULD have the `endTime` property."],
310+
profile_identifier="five-safes-crate",
311+
rocrate_entity_mod_sparql=sparql,
312+
)
313+
314+
315+
def test_5src_check_value_does_not_have_action_status_property():
316+
sparql = """
317+
PREFIX schema: <http://schema.org/>
318+
PREFIX shp: <https://w3id.org/shp#>
319+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
320+
321+
DELETE {
322+
?s schema:actionStatus ?o .
323+
}
324+
WHERE {
325+
?s schema:additionalType shp:CheckValue ;
326+
schema:actionStatus ?o .
327+
}
328+
"""
329+
330+
do_entity_test(
331+
rocrate_path=ValidROC().five_safes_crate_result,
332+
requirement_severity=Severity.RECOMMENDED,
333+
expected_validation_result=False,
334+
expected_triggered_requirements=["CheckValue"],
335+
expected_triggered_issues=["CheckValue SHOULD have actionStatus property."],
336+
profile_identifier="five-safes-crate",
337+
rocrate_entity_mod_sparql=sparql,
338+
)
339+
340+
341+
342+
def test_5src_check_value_does_not_point_to_an_agent():
343+
sparql = """
344+
PREFIX schema: <http://schema.org/>
345+
PREFIX shp: <https://w3id.org/shp#>
346+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
347+
348+
DELETE {
349+
?s schema:agent ?o .
350+
}
351+
WHERE {
352+
?s schema:additionalType shp:CheckValue ;
353+
schema:agent ?o .
354+
}
355+
"""
356+
357+
do_entity_test(
358+
rocrate_path=ValidROC().five_safes_crate_result,
359+
requirement_severity=Severity.RECOMMENDED,
360+
expected_validation_result=False,
361+
expected_triggered_requirements=["CheckValue"],
362+
expected_triggered_issues=["`CheckValue` --> `agent` SHOULD reference the agent who initiated the check"],
363+
profile_identifier="five-safes-crate",
364+
rocrate_entity_mod_sparql=sparql,
365+
)
204366

205367

206368
# ----- MAY fails tests

0 commit comments

Comments
 (0)