Skip to content

Commit 95ecd30

Browse files
committed
Added SHACL code and corresponding tests for licencing information in the ro-crate
1 parent 36f495a commit 95ecd30

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
@@ -59,22 +59,22 @@ five-safes-crate:RootDatasetDatePublishedWhenPublished
5959
]]
6060
) .
6161

62-
# five-safes-crate:RootDatasetLicenseWhenPublished
63-
# a sh:NodeShape ;
64-
# sh:name "License present on published crates" ;
65-
# sh:description "If the root dataset is published (has schema:publisher), it SHOULD declare a license." ;
66-
# sh:targetNode ro: ;
67-
# sh:severity sh:Warning ;
68-
# sh:message "Profile Conformance: Published crates SHOULD include a license." ;
69-
# sh:or (
70-
# # license not required if no publisher:
71-
# [ sh:not [ sh:property [
72-
# sh:path schema:publisher ;
73-
# sh:minCount 1 ;
74-
# ]]]
75-
# # license required if publisher present:
76-
# [ sh:property [
77-
# sh:path schema:license ;
78-
# sh:minCount 1 ;
79-
# ]]
80-
# ) .
62+
five-safes-crate:RootDatasetLicenseWhenPublished
63+
a sh:NodeShape ;
64+
sh:name "License present on published crates" ;
65+
sh:description "If the root dataset is published (has schema:publisher), it SHOULD declare a license." ;
66+
sh:targetNode ro: ;
67+
sh:severity sh:Warning ;
68+
sh:message "Profile Conformance: Published crates SHOULD include a license." ;
69+
sh:or (
70+
# license not required if no publisher:
71+
[ sh:not [ sh:property [
72+
sh:path schema:publisher ;
73+
sh:minCount 1 ;
74+
]]]
75+
# license required if publisher present:
76+
[ sh:property [
77+
sh:path schema:license ;
78+
sh:minCount 1 ;
79+
]]
80+
) .

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
@@ -126,4 +126,36 @@ def test_5src_root_data_entity_has_publisher_but_not_date_published():
126126
)
127127

128128

129+
def test_5src_root_data_entity_has_publisher_but_not_license():
130+
"""
131+
Test a Five Safes Crate where the RootDataEntity has publisher but not license.
132+
"""
133+
sparql = (
134+
SPARQL_PREFIXES
135+
+ """
136+
DELETE {
137+
?rootdataentity schema:license ?license .
138+
}
139+
WHERE {
140+
?metadatafile a schema:CreativeWork ;
141+
schema:about ?rootdataentity .
142+
?rootdataentity schema:publisher ?publisher ;
143+
schema:license ?license .
144+
}
145+
"""
146+
)
147+
148+
do_entity_test(
149+
rocrate_path=ValidROC().five_safes_crate_result,
150+
requirement_severity=Severity.RECOMMENDED,
151+
expected_validation_result=False,
152+
expected_triggered_requirements=["License present on published crates"],
153+
expected_triggered_issues=[
154+
"Profile Conformance: Published crates SHOULD include a license."
155+
],
156+
profile_identifier="five-safes-crate",
157+
rocrate_entity_mod_sparql=sparql,
158+
)
159+
160+
129161
# ----- MAY fails tests

0 commit comments

Comments
 (0)