From ee63df3a3ba5ee31792e95f7aaca390e5215a3ea Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 28 Jun 2024 12:20:36 -0400 Subject: [PATCH] Enforce InformationResource and NeverInformationResource disjointedness A follow-on patch will regenerate Make-managed files. References: * https://github.com/ucoProject/UCO/issues/619 Signed-off-by: Alex Nelson --- ontology/uco/core/core.ttl | 3 +- tests/examples/Makefile | 2 ++ tests/examples/information_resource_PASS.json | 7 ++--- .../examples/information_resource_XFAIL.json | 29 +++++++++++++++++++ tests/examples/test_validation.py | 11 ++++++- 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 tests/examples/information_resource_XFAIL.json diff --git a/ontology/uco/core/core.ttl b/ontology/uco/core/core.ttl index c2d616bc..bba04d4b 100644 --- a/ontology/uco/core/core.ttl +++ b/ontology/uco/core/core.ttl @@ -299,12 +299,11 @@ core:InformationResource core:InformationResource-disjointWith-NeverInformationResource-shape a sh:NodeShape ; - sh:message "core:InformationResource and core:NeverInformationResource are disjoint classes. Assigning both types to a single node will be an error as of UCO 2.0.0."@en ; + sh:message "core:InformationResource and core:NeverInformationResource are disjoint classes."@en ; sh:not [ a sh:NodeShape ; sh:class core:NeverInformationResource ; ] ; - sh:severity sh:Warning ; sh:targetClass core:InformationResource ; . diff --git a/tests/examples/Makefile b/tests/examples/Makefile index a41b2182..ffe8ddd0 100644 --- a/tests/examples/Makefile +++ b/tests/examples/Makefile @@ -38,6 +38,7 @@ all: \ hash_PASS_validation.ttl \ hash_XFAIL_validation.ttl \ information_resource_PASS_validation.ttl \ + information_resource_XFAIL_validation.ttl \ location_PASS_validation.ttl \ location_XFAIL_validation.ttl \ message_thread_PASS_validation.ttl \ @@ -114,6 +115,7 @@ check: \ hash_PASS_validation.ttl \ hash_XFAIL_validation.ttl \ information_resource_PASS_validation.ttl \ + information_resource_XFAIL_validation.ttl \ location_PASS_validation.ttl \ location_XFAIL_validation.ttl \ message_thread_PASS_validation.ttl \ diff --git a/tests/examples/information_resource_PASS.json b/tests/examples/information_resource_PASS.json index 12af7bbf..ecdd397e 100644 --- a/tests/examples/information_resource_PASS.json +++ b/tests/examples/information_resource_PASS.json @@ -9,13 +9,9 @@ "@graph": [ { "@id": "http://example.org/~bob", - "@type": [ - "identity:Person", - "observable:WebPage" - ], + "@type": "observable:WebResource", "core:name": "Bob", "core:description": "Bob's company home page.", - "rdfs:comment": "This node will trigger a warning from conflating a node as both a person and the person's home page.", "rdfs:seeAlso": [ { "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549" @@ -25,6 +21,7 @@ } ] }, + { "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549", "@type": "identity:Person", diff --git a/tests/examples/information_resource_XFAIL.json b/tests/examples/information_resource_XFAIL.json new file mode 100644 index 00000000..b1f7f080 --- /dev/null +++ b/tests/examples/information_resource_XFAIL.json @@ -0,0 +1,29 @@ +{ + "@context": { + "core": "https://ontology.unifiedcyberontology.org/uco/core/", + "kb": "http://example.org/kb/", + "identity": "https://ontology.unifiedcyberontology.org/uco/identity/", + "observable": "https://ontology.unifiedcyberontology.org/uco/observable/", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#" + }, + "@graph": [ + { + "@id": "http://example.org/~bob", + "@type": [ + "identity:Person", + "observable:WebPage" + ], + "core:name": "Bob", + "core:description": "Bob's company home page.", + "rdfs:comment": "This node will trigger an error from conflating a node as both a person and the person's home page.", + "rdfs:seeAlso": [ + { + "@id": "kb:Person-a3d3af3d-ea1d-47f6-bc02-ac334ded6549" + }, + { + "@id": "kb:WebPage-1c05c378-124e-4d3c-898a-fb5a8d178cf8" + } + ] + } + ] +} diff --git a/tests/examples/test_validation.py b/tests/examples/test_validation.py index b6531d28..2edb1633 100644 --- a/tests/examples/test_validation.py +++ b/tests/examples/test_validation.py @@ -298,7 +298,6 @@ def test_information_resource_PASS_validation() -> None: "information_resource_PASS_validation.ttl", True, expected_focus_node_severities={ - ("http://example.org/~bob", str(NS_SH.Warning)), ("http://example.org/~bob", str(NS_SH.Info)), ("http://example.org/~chris", str(NS_SH.Info)), ("https://mc.example.co.jp/", str(NS_SH.Info)), @@ -306,6 +305,16 @@ def test_information_resource_PASS_validation() -> None: } ) +def test_information_resource_XFAIL_validation() -> None: + confirm_validation_results( + "information_resource_XFAIL_validation.ttl", + False, + expected_focus_node_severities={ + ("http://example.org/~bob", str(NS_SH.Info)), + ("http://example.org/~bob", str(NS_SH.Violation)), + } + ) + def test_co_PASS_validation() -> None: confirm_validation_results("co_PASS_validation.ttl", True)