Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Do not merge) Draft OC-191 #321

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
108 changes: 86 additions & 22 deletions tests/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,31 @@ all: \
action_inheritance_XFAIL_validation.ttl \
action_result_PASS_validation.ttl \
location_PASS_validation.ttl \
location_XFAIL_validation.ttl
location_XFAIL_validation.ttl \
relationship_PASS_validation.ttl \
relationship_PASS_via_rdflib_validation_after_translation.ttl \
relationship_PASS_via_rdf_toolkit_validation_after_translation.ttl \
relationship_XFAIL_validation.ttl

.PHONY: \
check-context

.PRECIOUS: \
%_PASS_validation.ttl \
%_XFAIL_validation.ttl
%_validation.ttl \
relationship_PASS_via_rdflib.ttl \
relationship_PASS_via_rdf_toolkit.ttl

%_PASS_validation.ttl: \
%_PASS.json \
# NOTE - this recipe makes an allowance for a certain failure type
# reported by pyshacl. Pyshacl will exit status 1 in the case where
# "DataGraph is Non-Conformant". This XFAIL test is intenced to
# generate a non-conformance result, and feed that result forward to
# pytest. Hence, the Make recipe allows for an exit status of 0 or 1.
# (0 would cause an expected failure later in pytest.)
# Note that should another issue cause an exit status of 1, pytest will
# fail because the result validation-graph file would not have expected
# characteristics.
%_validation.ttl: \
%.json \
$(tests_srcdir)/.venv.done.log \
$(tests_srcdir)/uco_monolithic.ttl
source $(tests_srcdir)/venv/bin/activate \
Expand All @@ -41,48 +58,95 @@ all: \
--ont-graph $(tests_srcdir)/uco_monolithic.ttl \
--shacl $(tests_srcdir)/uco_monolithic.ttl \
--shacl-file-format turtle \
--output _$@ \
--output __$@ \
$< \
|| (cat _$@ ; exit 1)
; rc=$$? ; test 0 -eq $$rc -o 1 -eq $$rc
java -jar $(top_srcdir)/lib/rdf-toolkit.jar \
--infer-base-iri \
--inline-blank-nodes \
--source __$@ \
--source-format turtle \
--target _$@ \
--target-format turtle
rm __$@
mv _$@ $@

# NOTE - this recipe makes an allowance for a certain failure type
# reported by pyshacl. Pyshacl will exit status 1 in the case where
# "DataGraph is Non-Conformant". This XFAIL test is intenced to
# generate a non-conformance result, and feed that result forward to
# pytest. Hence, the Make recipe allows for an exit status of 0 or 1.
# (0 would cause an expected failure later in pytest.)
# Note that should another issue cause an exit status of 1, pytest will
# fail because the result validation-graph file would not have expected
# characteristics.
%_XFAIL_validation.ttl: \
%_XFAIL.json \
%_validation_after_translation.ttl: \
%.ttl \
$(tests_srcdir)/.venv.done.log \
$(tests_srcdir)/uco_monolithic.ttl
source $(tests_srcdir)/venv/bin/activate \
&& pyshacl \
--data-file-format json-ld \
--data-file-format turtle \
--format turtle \
--inference none \
--ont-file-format turtle \
--ont-graph $(tests_srcdir)/uco_monolithic.ttl \
--shacl $(tests_srcdir)/uco_monolithic.ttl \
--shacl-file-format turtle \
--output _$@ \
--output __$@ \
$< \
; rc=$$? ; test 0 -eq $$rc -o 1 -eq $$rc
java -jar $(top_srcdir)/lib/rdf-toolkit.jar \
--infer-base-iri \
--inline-blank-nodes \
--source __$@ \
--source-format turtle \
--target _$@ \
--target-format turtle
rm __$@
mv _$@ $@

check: \
action_inheritance_PASS_validation.ttl \
action_inheritance_XFAIL_validation.ttl \
action_result_PASS_validation.ttl \
check-context \
location_PASS_validation.ttl \
location_XFAIL_validation.ttl
location_XFAIL_validation.ttl \
relationship_PASS_validation.ttl \
relationship_PASS_via_rdflib_validation_after_translation.ttl \
relationship_PASS_via_rdf_toolkit_validation_after_translation.ttl \
relationship_XFAIL_validation.ttl
source $(tests_srcdir)/venv/bin/activate \
&& pytest \
--log-level=DEBUG

# These Turtle renders of the JSON file are for confirming data characteristics are preserved when consumed by multiple RDF applications.
check-context: \
relationship_PASS_via_rdflib.ttl \
relationship_PASS_via_rdf_toolkit.ttl
diff $^

clean:
@rm -f \
*_validation.ttl
*_validation*.ttl

relationship_PASS_via_rdf_toolkit.ttl: \
relationship_PASS.json
java -jar $(top_srcdir)/lib/rdf-toolkit.jar \
--infer-base-iri \
--inline-blank-nodes \
--source $< \
--source-format json-ld \
--target _$@ \
--target-format turtle
mv _$@ $@

relationship_PASS_via_rdflib.ttl: \
relationship_PASS.json \
$(tests_srcdir)/.venv.done.log \
$(tests_srcdir)/src/glom_graph.py
source $(tests_srcdir)/venv/bin/activate \
&& python3 $(tests_srcdir)/src/glom_graph.py \
__$@ \
$<
java -jar $(top_srcdir)/lib/rdf-toolkit.jar \
--infer-base-iri \
--inline-blank-nodes \
--source __$@ \
--source-format turtle \
--target _$@ \
--target-format turtle
rm __$@
mv _$@ $@
9 changes: 7 additions & 2 deletions tests/examples/action_inheritance_PASS_validation.ttl
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

[] a sh:ValidationReport ;
sh:conforms true .
[]
a sh:ValidationReport ;
sh:conforms "true"^^xsd:boolean ;
.

Loading