Skip to content

Commit b7a61fe

Browse files
committed
Add SHACL shapes to set of CDO concepts
This patch adds a test to reproduce the discovery of Issue 85. A follow-on patch will regenerate Make-managed files. References: * #85 Signed-off-by: Alex Nelson <[email protected]>
1 parent d6761af commit b7a61fe

File tree

5 files changed

+96
-2
lines changed

5 files changed

+96
-2
lines changed

case_utils/case_validate/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
NS_OWL = rdflib.OWL
5252
NS_RDF = rdflib.RDF
5353
NS_RDFS = rdflib.RDFS
54+
NS_SH = rdflib.SH
5455

5556
_logger = logging.getLogger(os.path.basename(__file__))
5657

@@ -189,6 +190,9 @@ def main() -> None:
189190
NS_OWL.DatatypeProperty,
190191
NS_OWL.ObjectProperty,
191192
NS_RDFS.Datatype,
193+
NS_SH.NodeShape,
194+
NS_SH.PropertyShape,
195+
NS_SH.Shape,
192196
]:
193197
for ontology_triple in ontology_graph.triples(
194198
(None, NS_RDF.type, n_structural_class)

tests/case_utils/case_validate/Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ tests_srcdir := $(top_srcdir)/tests
2727
all: \
2828
all-cli \
2929
all-case_test_examples \
30-
all-uco_test_examples
30+
all-uco_test_examples \
31+
all-shape_disabling
3132

3233
.PHONY: \
3334
all-case_test_examples \
3435
all-cli \
36+
all-shape_disabling \
3537
all-uco_test_examples \
3638
check-case_test_examples \
3739
check-cli \
40+
check-shape_disabling \
3841
check-uco_test_examples
3942

4043
all-case_test_examples:
@@ -45,14 +48,19 @@ all-cli:
4548
$(MAKE) \
4649
--directory cli
4750

51+
all-shape_disabling:
52+
$(MAKE) \
53+
--directory shape_disabling
54+
4855
all-uco_test_examples:
4956
$(MAKE) \
5057
--directory uco_test_examples
5158

5259
check: \
5360
check-cli \
5461
check-case_test_examples \
55-
check-uco_test_examples
62+
check-uco_test_examples \
63+
check-shape_disabling
5664

5765
check-case_test_examples:
5866
$(MAKE) \
@@ -64,13 +72,21 @@ check-cli:
6472
--directory cli \
6573
check
6674

75+
check-shape_disabling:
76+
$(MAKE) \
77+
--directory shape_disabling \
78+
check
79+
6780
check-uco_test_examples: \
6881
uco_monolithic.ttl
6982
$(MAKE) \
7083
--directory uco_test_examples \
7184
check
7285

7386
clean:
87+
@$(MAKE) \
88+
--directory shape_disabling \
89+
clean
7490
@$(MAKE) \
7591
--directory case_test_examples \
7692
clean
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/make -f
2+
3+
# This software was developed at the National Institute of Standards
4+
# and Technology by employees of the Federal Government in the course
5+
# of their official duties. Pursuant to title 17 Section 105 of the
6+
# United States Code this software is not subject to copyright
7+
# protection and is in the public domain. NIST assumes no
8+
# responsibility whatsoever for its use by other parties, and makes
9+
# no guarantees, expressed or implied, about its quality,
10+
# reliability, or any other characteristic.
11+
#
12+
# We would appreciate acknowledgement if the software is used.
13+
14+
SHELL := /bin/bash
15+
16+
top_srcdir := $(shell cd ../../../.. ; pwd)
17+
18+
tests_srcdir := $(top_srcdir)/tests
19+
20+
all: \
21+
validation_with_uuid_shape_disabled.txt \
22+
validation_with_uuid_shape_enabled.txt
23+
24+
check: \
25+
validation_with_uuid_shape_disabled.txt \
26+
validation_with_uuid_shape_enabled.txt
27+
28+
clean:
29+
@rm -f \
30+
*.txt \
31+
_*
32+
33+
validation_with_uuid_shape_disabled.txt: \
34+
$(tests_srcdir)/.venv.done.log \
35+
disable_shape.ttl \
36+
example.ttl
37+
source $(tests_srcdir)/venv/bin/activate \
38+
&& case_validate \
39+
--ontology disable_shape.ttl \
40+
example.ttl \
41+
> _$@
42+
mv _$@ $@
43+
44+
validation_with_uuid_shape_enabled.txt: \
45+
$(tests_srcdir)/.venv.done.log \
46+
example.ttl
47+
source $(tests_srcdir)/venv/bin/activate \
48+
&& case_validate \
49+
--allow-infos \
50+
example.ttl \
51+
> _$@
52+
mv _$@ $@
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix sh: <http://www.w3.org/ns/shacl#> .
5+
@prefix uco-core: <https://ontology.unifiedcyberontology.org/uco/core/> .
6+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
7+
8+
uco-core:UcoThing-identifier-regex-shape
9+
sh:deactivated "true"^^xsd:boolean ;
10+
.
11+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix uco-core: <https://ontology.unifiedcyberontology.org/uco/core/> .
5+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
6+
7+
<urn:example:thing-1>
8+
a uco-core:UcoThing ;
9+
rdfs:comment "This node's IRI is designed to trigger a UUID review shape."@en ;
10+
.
11+

0 commit comments

Comments
 (0)