Skip to content

Commit 36f495a

Browse files
committed
Added SHACL code and corresponding tests about RootDataEntity having a publishedDate if it has a publisher.
1 parent 43289a5 commit 36f495a

2 files changed

Lines changed: 51 additions & 19 deletions

File tree

rocrate_validator/profiles/five-safes-crate/should/5_profile_conformance.ttl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ five-safes-crate:RootDatasetConformsToFiveSafes
3939
sh:message "Root Dataset SHOULD include `conformsTo` https://w3id.org/5s-crate/0.4" ;
4040
] .
4141

42-
# five-safes-crate:RootDatasetDatePublishedWhenPublished
43-
# a sh:NodeShape ;
44-
# sh:name "datePublished present on published crates" ;
45-
# sh:description "If the root dataset is published (has schema:publisher), it SHOULD have schema:datePublished." ;
46-
# sh:targetNode ro: ;
47-
# sh:severity sh:Warning ;
48-
# sh:message "Published crates SHOULD include schema:datePublished." ;
49-
# sh:or (
50-
# # datePublished not required if no publisher:
51-
# [ sh:not [ sh:property [
52-
# sh:path schema:publisher ;
53-
# sh:minCount 1 ;
54-
# ]]]
55-
# # datePublished required if publisher present:
56-
# [ sh:property [
57-
# sh:path schema:datePublished ;
58-
# sh:minCount 1 ;
59-
# ]]
60-
# ) .
42+
five-safes-crate:RootDatasetDatePublishedWhenPublished
43+
a sh:NodeShape ;
44+
sh:name "datePublished present on published crates" ;
45+
sh:description "If the root dataset is published (has schema:publisher), it SHOULD have schema:datePublished." ;
46+
sh:targetClass ro-crate:RootDataEntity ;
47+
sh:severity sh:Warning ;
48+
sh:message "Published crates SHOULD include schema:datePublished." ;
49+
sh:or (
50+
# datePublished not required if no publisher:
51+
[ sh:not [ sh:property [
52+
sh:path schema:publisher ;
53+
sh:minCount 1 ;
54+
]]]
55+
# datePublished required if publisher present:
56+
[ sh:property [
57+
sh:path schema:datePublished ;
58+
sh:minCount 1 ;
59+
]]
60+
) .
6161

6262
# five-safes-crate:RootDatasetLicenseWhenPublished
6363
# a sh:NodeShape ;

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,36 @@ def test_5src_root_data_entity_conforms_to_wrong_profile():
9494
)
9595

9696

97+
def test_5src_root_data_entity_has_publisher_but_not_date_published():
98+
"""
99+
Test a Five Safes Crate where the RootDataEntity has published but not date published.
100+
"""
101+
sparql = (
102+
SPARQL_PREFIXES
103+
+ """
104+
DELETE {
105+
?rootdataentity schema:datePublished ?datePublished .
106+
}
107+
WHERE {
108+
?metadatafile a schema:CreativeWork ;
109+
schema:about ?rootdataentity .
110+
?rootdataentity schema:publisher ?publisher ;
111+
schema:datePublished ?datePublished .
112+
}
113+
"""
114+
)
115+
116+
do_entity_test(
117+
rocrate_path=ValidROC().five_safes_crate_result,
118+
requirement_severity=Severity.RECOMMENDED,
119+
expected_validation_result=False,
120+
expected_triggered_requirements=["datePublished present on published crates"],
121+
expected_triggered_issues=[
122+
"Published crates SHOULD include schema:datePublished."
123+
],
124+
profile_identifier="five-safes-crate",
125+
rocrate_entity_mod_sparql=sparql,
126+
)
127+
128+
97129
# ----- MAY fails tests

0 commit comments

Comments
 (0)