diff --git a/case_utils/case_validate/__init__.py b/case_utils/case_validate/__init__.py index a97e0ff..34a317d 100644 --- a/case_utils/case_validate/__init__.py +++ b/case_utils/case_validate/__init__.py @@ -51,6 +51,7 @@ NS_OWL = rdflib.OWL NS_RDF = rdflib.RDF NS_RDFS = rdflib.RDFS +NS_SH = rdflib.SH _logger = logging.getLogger(os.path.basename(__file__)) @@ -189,6 +190,9 @@ def main() -> None: NS_OWL.DatatypeProperty, NS_OWL.ObjectProperty, NS_RDFS.Datatype, + NS_SH.NodeShape, + NS_SH.PropertyShape, + NS_SH.Shape, ]: for ontology_triple in ontology_graph.triples( (None, NS_RDF.type, n_structural_class) diff --git a/tests/case_utils/case_validate/Makefile b/tests/case_utils/case_validate/Makefile index b6bf821..aa5a489 100644 --- a/tests/case_utils/case_validate/Makefile +++ b/tests/case_utils/case_validate/Makefile @@ -27,14 +27,17 @@ tests_srcdir := $(top_srcdir)/tests all: \ all-cli \ all-case_test_examples \ - all-uco_test_examples + all-uco_test_examples \ + all-shape_disabling .PHONY: \ all-case_test_examples \ all-cli \ + all-shape_disabling \ all-uco_test_examples \ check-case_test_examples \ check-cli \ + check-shape_disabling \ check-uco_test_examples all-case_test_examples: @@ -45,6 +48,10 @@ all-cli: $(MAKE) \ --directory cli +all-shape_disabling: + $(MAKE) \ + --directory shape_disabling + all-uco_test_examples: $(MAKE) \ --directory uco_test_examples @@ -52,7 +59,8 @@ all-uco_test_examples: check: \ check-cli \ check-case_test_examples \ - check-uco_test_examples + check-uco_test_examples \ + check-shape_disabling check-case_test_examples: $(MAKE) \ @@ -64,6 +72,11 @@ check-cli: --directory cli \ check +check-shape_disabling: + $(MAKE) \ + --directory shape_disabling \ + check + check-uco_test_examples: \ uco_monolithic.ttl $(MAKE) \ @@ -71,6 +84,9 @@ check-uco_test_examples: \ check clean: + @$(MAKE) \ + --directory shape_disabling \ + clean @$(MAKE) \ --directory case_test_examples \ clean diff --git a/tests/case_utils/case_validate/shape_disabling/Makefile b/tests/case_utils/case_validate/shape_disabling/Makefile new file mode 100644 index 0000000..b9603ac --- /dev/null +++ b/tests/case_utils/case_validate/shape_disabling/Makefile @@ -0,0 +1,52 @@ +#!/usr/bin/make -f + +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to title 17 Section 105 of the +# United States Code this software is not subject to copyright +# protection and is in the public domain. NIST assumes no +# responsibility whatsoever for its use by other parties, and makes +# no guarantees, expressed or implied, about its quality, +# reliability, or any other characteristic. +# +# We would appreciate acknowledgement if the software is used. + +SHELL := /bin/bash + +top_srcdir := $(shell cd ../../../.. ; pwd) + +tests_srcdir := $(top_srcdir)/tests + +all: \ + validation_with_uuid_shape_disabled.txt \ + validation_with_uuid_shape_enabled.txt + +check: \ + validation_with_uuid_shape_disabled.txt \ + validation_with_uuid_shape_enabled.txt + +clean: + @rm -f \ + *.txt \ + _* + +validation_with_uuid_shape_disabled.txt: \ + $(tests_srcdir)/.venv.done.log \ + disable_shape.ttl \ + example.ttl + source $(tests_srcdir)/venv/bin/activate \ + && case_validate \ + --ontology disable_shape.ttl \ + example.ttl \ + > _$@ + mv _$@ $@ + +validation_with_uuid_shape_enabled.txt: \ + $(tests_srcdir)/.venv.done.log \ + example.ttl + source $(tests_srcdir)/venv/bin/activate \ + && case_validate \ + --allow-infos \ + example.ttl \ + > _$@ + mv _$@ $@ diff --git a/tests/case_utils/case_validate/shape_disabling/disable_shape.ttl b/tests/case_utils/case_validate/shape_disabling/disable_shape.ttl new file mode 100644 index 0000000..e9e9bf7 --- /dev/null +++ b/tests/case_utils/case_validate/shape_disabling/disable_shape.ttl @@ -0,0 +1,11 @@ +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix sh: . +@prefix uco-core: . +@prefix xsd: . + +uco-core:UcoThing-identifier-regex-shape + sh:deactivated "true"^^xsd:boolean ; + . + diff --git a/tests/case_utils/case_validate/shape_disabling/example.ttl b/tests/case_utils/case_validate/shape_disabling/example.ttl new file mode 100644 index 0000000..9f7a89c --- /dev/null +++ b/tests/case_utils/case_validate/shape_disabling/example.ttl @@ -0,0 +1,11 @@ +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix uco-core: . +@prefix xsd: . + + + a uco-core:UcoThing ; + rdfs:comment "This node's IRI is designed to trigger a UUID review shape."@en ; + . + diff --git a/tests/case_utils/case_validate/shape_disabling/validation_with_uuid_shape_disabled.txt b/tests/case_utils/case_validate/shape_disabling/validation_with_uuid_shape_disabled.txt new file mode 100644 index 0000000..0c16da6 --- /dev/null +++ b/tests/case_utils/case_validate/shape_disabling/validation_with_uuid_shape_disabled.txt @@ -0,0 +1,2 @@ +Validation Report +Conforms: True diff --git a/tests/case_utils/case_validate/shape_disabling/validation_with_uuid_shape_enabled.txt b/tests/case_utils/case_validate/shape_disabling/validation_with_uuid_shape_enabled.txt new file mode 100644 index 0000000..1e6b23f --- /dev/null +++ b/tests/case_utils/case_validate/shape_disabling/validation_with_uuid_shape_enabled.txt @@ -0,0 +1,23 @@ +Validation Report +Conforms: True +Results (1): +Validation Result in SPARQLConstraintComponent (http://www.w3.org/ns/shacl#SPARQLConstraintComponent): + Severity: sh:Info + Source Shape: core:UcoThing-identifier-regex-shape + Focus Node: + Value Node: + Source Constraint: [ rdf:type sh:SPARQLConstraint ; rdfs:seeAlso ; sh:message Literal("UcoThings are suggested to end with a UUID.", lang=en) ; sh:select Literal(" + PREFIX uco-core: + SELECT $this + WHERE { + $this a/rdfs:subClassOf* uco-core:UcoThing . + FILTER ( + ! REGEX ( + STR($this), + "[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$", + "i" + ) + ) + } + ") ] + Message: UcoThings are suggested to end with a UUID.