Skip to content

Commit 3901840

Browse files
Merge pull request #24 from casework/AC-210
AC-210
2 parents c42df16 + 822d2a1 commit 3901840

File tree

7 files changed

+82
-6
lines changed

7 files changed

+82
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This repository provides `case_validate` as an adaptation of the `pyshacl` comma
2727
To see a human-readable validation report of an instance-data file:
2828

2929
```bash
30-
case_validate input.json
30+
case_validate input.json [input-2.json ...]
3131
```
3232

3333
If `input.json` is not conformant, a report will be emitted, and `case_validate` will exit with status `1`. (This is a `pyshacl` behavior, where `0` and `1` report validation success. Status of >`1` is for other errors.)

case_utils/case_validate/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main() -> None:
5656
# parser.
5757
logging.basicConfig(level=logging.DEBUG if ("--debug" in sys.argv or "-d" in sys.argv) else logging.INFO)
5858

59-
case_version_choices_list = ["none", "case-" + CURRENT_CASE_VERSION]
59+
built_version_choices_list = ["none", "case-" + CURRENT_CASE_VERSION]
6060

6161
# Add arguments specific to case_validate.
6262
parser.add_argument(
@@ -67,7 +67,7 @@ def main() -> None:
6767
)
6868
parser.add_argument(
6969
"--built-version",
70-
choices=tuple(case_version_choices_list),
70+
choices=tuple(built_version_choices_list),
7171
default="case-"+CURRENT_CASE_VERSION,
7272
help="Monolithic aggregation of CASE ontology files at certain versions. Does not require networking to use. Default is most recent CASE release."
7373
)
@@ -119,12 +119,14 @@ def main() -> None:
119119
default=sys.stdout,
120120
)
121121

122-
parser.add_argument("in_graph")
122+
parser.add_argument("in_graph", nargs="+")
123123

124124
args = parser.parse_args()
125125

126126
data_graph = rdflib.Graph()
127-
data_graph.parse(args.in_graph)
127+
for in_graph in args.in_graph:
128+
_logger.debug("in_graph = %r.", in_graph)
129+
data_graph.parse(in_graph)
128130

129131
ontology_graph = rdflib.Graph()
130132
if args.built_version != "none":

tests/case_utils/case_validate/cli/Makefile

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ files_to_generate := \
3939
format_unspecified_output_jsonld.jsonld \
4040
format_unspecified_output_turtle.ttl \
4141
format_unspecified_output_txt.txt \
42-
format_unspecified_output_unspecified.txt
42+
format_unspecified_output_unspecified.txt \
43+
split_data_graph_PASS.txt \
44+
split_data_graph_XFAIL.txt
4345

4446
all: \
4547
$(files_to_generate)
@@ -183,3 +185,34 @@ format_unspecified_output_unspecified.txt: \
183185
$< \
184186
> _$@
185187
mv _$@ $@
188+
189+
split_data_graph_PASS.txt: \
190+
$(tests_srcdir)/.venv.done.log \
191+
$(top_srcdir)/.ontology.done.log \
192+
$(top_srcdir)/case_utils/case_validate/__init__.py \
193+
$(top_srcdir)/case_utils/ontology/__init__.py \
194+
split_data_graph_1.json \
195+
split_data_graph_2.json
196+
rm -f _$@
197+
source $(tests_srcdir)/venv/bin/activate \
198+
&& case_validate \
199+
--debug \
200+
split_data_graph_1.json \
201+
split_data_graph_2.json \
202+
> _$@
203+
mv _$@ $@
204+
205+
split_data_graph_XFAIL.txt: \
206+
$(tests_srcdir)/.venv.done.log \
207+
$(top_srcdir)/.ontology.done.log \
208+
$(top_srcdir)/case_utils/case_validate/__init__.py \
209+
$(top_srcdir)/case_utils/ontology/__init__.py \
210+
split_data_graph_1.json
211+
rm -f _$@
212+
source $(tests_srcdir)/venv/bin/activate \
213+
&& case_validate \
214+
--debug \
215+
split_data_graph_1.json \
216+
> _$@ \
217+
; rc=$$? ; test 1 -eq $$rc
218+
mv _$@ $@
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"@context": {
3+
"kb": "http://example.org/kb/",
4+
"case-investigation": "https://ontology.caseontology.org/case/investigation/",
5+
"uco-core": "https://unifiedcyberontology.org/ontology/uco/core#"
6+
},
7+
"@graph": [
8+
{
9+
"@id": "kb:provenance-record-1",
10+
"@type": "case-investigation:ProvenanceRecord",
11+
"uco-core:object": {
12+
"@id": "kb:file-1"
13+
}
14+
}
15+
]
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"kb": "http://example.org/kb/",
4+
"uco-observable": "https://unifiedcyberontology.org/ontology/uco/observable#"
5+
},
6+
"@graph": [
7+
{
8+
"@id": "kb:file-1",
9+
"@type": "uco-observable:File"
10+
}
11+
]
12+
}
13+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Validation Report
2+
Conforms: True
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Validation Report
2+
Conforms: False
3+
Results (1):
4+
Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
5+
Severity: sh:Violation
6+
Source Shape: [ sh:class core:UcoObject ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:nodeKind sh:BlankNodeOrIRI ; sh:path core:object ]
7+
Focus Node: kb:provenance-record-1
8+
Value Node: kb:file-1
9+
Result Path: core:object
10+
Message: Value does not have class core:UcoObject

0 commit comments

Comments
 (0)