Skip to content

Commit 1cc26d4

Browse files
committed
Addressed Eli's comments on PR.
1 parent 9574808 commit 1cc26d4

3 files changed

Lines changed: 72 additions & 42 deletions

File tree

rocrate_validator/profiles/five-safes-crate/must/10_outputs.ttl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ five-safes-crate:CreateActionResultOutputsDefined
2727
a sh:NodeShape ;
2828
sh:name "CreateAction" ;
2929
sh:targetClass schema:CreateAction ;
30-
sh:message "The result of a schema:CreateAction must be a defined node (must have an rdf:type)." ;
30+
sh:message "The result of a schema:CreateAction must be a defined node (must have `@type`)." ;
3131
sh:property [
3232
sh:name "result" ;
3333
sh:path schema:result ;
3434
sh:node five-safes-crate:DefinedNodeShape ;
35-
sh:description "The result of a schema:CreateAction must be a defined node (must have an rdf:type)." ;
35+
sh:description "The result of a schema:CreateAction must be a defined node (must have `@type`)." ;
3636
] .
3737

3838
five-safes-crate:DefinedNodeShape
3939
a sh:NodeShape ;
4040
sh:name "DefinedNode" ;
41-
sh:message "Result node is not defined in the RO-Crate (no rdf:type triple)." ;
41+
sh:message "Result node is not defined in the RO-Crate (it does not have its own entry in `@graph` with a `@type` attribute defined)." ;
4242
sh:property [
4343
sh:name "type" ;
4444
sh:path rdf:type ;
4545
sh:minCount 1 ;
46-
sh:message "Result node is not defined in the RO-Crate (no rdf:type triple)." ;
46+
sh:message "Result node is not defined in the RO-Crate (it does not have its own entry in `@graph` with a `@type` attribute defined)." ;
4747
sh:severity sh:Violation ;
4848
] .

rocrate_validator/profiles/five-safes-crate/should/10_outputs.ttl

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,41 +51,38 @@ five-safes-crate:CreateActionHasResultIfActionCompleted
5151
] .
5252

5353

54+
five-safes-crate:CreateActionResultOutputsHaveAllowedTypes
55+
a sh:NodeShape ;
56+
sh:name "Output" ;
57+
sh:description "Result SHOULD have a `@type` among an allowed set of values." ;
58+
sh:target [
59+
a sh:SPARQLTarget ;
60+
sh:select """
61+
PREFIX schema: <http://schema.org/>
62+
SELECT ?this
63+
WHERE {
64+
?createAction a schema:CreateAction .
65+
?createAction schema:result ?this .
66+
}
67+
""" ;
68+
] ;
69+
sh:message "Result SHOULD have a `@type` among an allowed set of values." ;
70+
sh:severity sh:Warning ;
71+
sh:or (
72+
[
73+
sh:class schema:MediaObject;
74+
]
75+
[
76+
sh:class schema:Dataset;
77+
]
78+
[
79+
sh:class schema:Collection;
80+
]
81+
[
82+
sh:class schema:DigitalDocument;
83+
]
84+
[
85+
sh:class schema:PropertyValue;
86+
]
87+
) .
5488

55-
# This test passes even when it should fail, so it is disabled for now.
56-
# According to Clause.ai the possible reason for this misbehaviour is that
57-
# the RO-Crate validator adds inferred types like schema:MediaObject to the
58-
# entity based on other characteristics (like it being a file). So the entity
59-
# has BOTH "Filexx" (which doesn't expand to a schema.org URI) AND the inferred
60-
# schema:MediaObject, which makes the constraint pass.
61-
# The fundamental problem is that we can't easily distinguish between
62-
# user-declared types and validator-inferred types in the materialized RDF graph.
63-
64-
# five-safes-crate:CreateActionResultOutputsHaveAllowedTypes
65-
# a sh:NodeShape ;
66-
# sh:name "Output" ;
67-
# sh:target [
68-
# a sh:SPARQLTarget ;
69-
# sh:select """
70-
# PREFIX schema: <http://schema.org/>
71-
# SELECT ?this
72-
# WHERE {
73-
# ?createAction a schema:CreateAction .
74-
# ?createAction schema:result ?this .
75-
# }
76-
# """ ;
77-
# ] ;
78-
# sh:message "Every schema:result must point to a defined node (must have an rdf:type)." ;
79-
# sh:property [
80-
# sh:path rdf:type ;
81-
# sh:qualifiedValueShape (
82-
# schema:MediaObject
83-
# schema:Dataset
84-
# schema:Collection
85-
# schema:DigitalDocument
86-
# schema:PropertyValue
87-
# ) ;
88-
# sh:qualifiedMinCount 1 ;
89-
# sh:message "Result has a rdf:type outside the allowed set." ;
90-
# sh:severity sh:Warning ;
91-
# ] .

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,40 @@ def test_completed_createaction_does_not_have_result():
7979

8080
do_entity_test(
8181
rocrate_path=ValidROC().five_safes_crate_request,
82-
requirement_severity=Severity.REQUIRED,
82+
requirement_severity=Severity.RECOMMENDED,
83+
expected_validation_result=False,
84+
expected_triggered_requirements=None,
85+
expected_triggered_issues=None,
86+
profile_identifier="five-safes-crate",
87+
rocrate_entity_mod_sparql=sparql,
88+
)
89+
90+
91+
def test_result_output_does_not_have_allowed_type():
92+
"""
93+
Test a Five Safes Crate where the result output does not have a type that
94+
is among those allowed.
95+
(We remove the output entity and replace it with one that is of a wrong type)"""
96+
sparql = (
97+
SPARQL_PREFIXES
98+
+ """
99+
DELETE {
100+
?result a ?oldType .
101+
}
102+
INSERT {
103+
?result a schema:Person .
104+
}
105+
WHERE {
106+
?action a schema:CreateAction ;
107+
schema:result ?result .
108+
?result a ?oldType .
109+
}
110+
"""
111+
)
112+
113+
do_entity_test(
114+
rocrate_path=ValidROC().five_safes_crate_request,
115+
requirement_severity=Severity.RECOMMENDED,
83116
expected_validation_result=False,
84117
expected_triggered_requirements=None,
85118
expected_triggered_issues=None,

0 commit comments

Comments
 (0)