From 68a14544d4f6276c4ee0ddefedd2b7f29e6f819b Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Tue, 15 Aug 2023 16:00:05 -0400 Subject: [PATCH] Integrate monolithic build into coverage test This addresses an issue where a subclass relationship not explicitly noted in the profile graph gets missed when reviewing whether a higher-level concept has been tested. E.g. when reviewing the Endurant vs Perdurant proposal (UCO Issue 544), had the following statements: Profile graph: ```turtle uco-core:Item rdfs:subClassOf drafting:Endurant ; . ``` Exemplars graph: ```turtle kb:File-e364d7d2-25c8-4d4a-95d1-b03f73934e83 a uco-observable:File ; . ``` Upstream, UCO contains subclass statements that tie `uco-observable:File` to `uco-core:Item`, but the profiles graph did not contain those axioms. So, the exemplars coverage test failed, reporting that `core:Item` had not been demonstrated. After this patch, exemplars coverage now respects all imported subclass hierarchies. References: * https://github.com/ucoProject/UCO/issues/544 Signed-off-by: Alex Nelson --- tests/Makefile | 2 +- tests/test_exemplar_coverage.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index d9ab0d5..ca8139e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -39,8 +39,8 @@ all: \ touch $@ .pytest.done.log: \ - $(profile_ttls) \ exemplars.ttl \ + monolithic.ttl \ test_exemplar_coverage.py source $(top_srcdir)/venv/bin/activate \ && pytest \ diff --git a/tests/test_exemplar_coverage.py b/tests/test_exemplar_coverage.py index 733104d..b5388a5 100644 --- a/tests/test_exemplar_coverage.py +++ b/tests/test_exemplar_coverage.py @@ -37,6 +37,7 @@ def test_exemplar_coverage() -> None: """ exemplar_graph = Graph() profile_graph = Graph() + tbox_graph = Graph() combined_graph = Graph() for filepath in (top_srcdir / "ontology").iterdir(): @@ -48,12 +49,15 @@ def test_exemplar_coverage() -> None: profile_graph.parse(filepath) logging.debug("len(profile_graph) = %d.", len(profile_graph)) + monolithic_filepath = srcdir / "monolithic.ttl" + tbox_graph.parse(monolithic_filepath) + exemplar_filepath = srcdir / "exemplars.ttl" logging.debug("Loading exemplars graph %r.", exemplar_filepath) exemplar_graph.parse(exemplar_filepath) logging.debug("len(exemplar_graph) = %d.", len(exemplar_graph)) - combined_graph = exemplar_graph + profile_graph + combined_graph = exemplar_graph + tbox_graph classes_mapped: Set[URIRef] = set() classes_with_exemplars: Set[URIRef] = set()