diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..c76fd19
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..874f6c7
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/ruff.xml b/.idea/ruff.xml
new file mode 100644
index 0000000..d0d27da
--- /dev/null
+++ b/.idea/ruff.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9243cb4..7e2b13b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
+### Fixed
+
+- Ontology graphs can now be selected as the context graph
+
### Changed
- updated dependencies and template
diff --git a/cmem_plugin_validation/validate_graph/task.py b/cmem_plugin_validation/validate_graph/task.py
index 40fd2e4..6a990a3 100644
--- a/cmem_plugin_validation/validate_graph/task.py
+++ b/cmem_plugin_validation/validate_graph/task.py
@@ -31,6 +31,12 @@
according to the node shapes in a shape catalog graph.
"""
+CONTEXT_GRAPH_CLASSES = [
+ "https://vocab.eccenca.com/di/Dataset",
+ "http://rdfs.org/ns/void#Dataset",
+ "https://vocab.eccenca.com/shui/QueryCatalog",
+ "http://www.w3.org/2002/07/owl#Ontology",
+]
DEFAULT_SHAPE_GRAPH = "https://vocab.eccenca.com/shacl/"
DEFAULT_RESULT_GRAPH = ""
DEFAULT_CLEAR_RESULT_GRAPH = False
@@ -54,6 +60,7 @@
label="Context Graph",
description="This graph holds the resources you want to validate.",
param_type=GraphParameterType(
+ classes=CONTEXT_GRAPH_CLASSES,
show_di_graphs=False,
show_graphs_without_class=True,
show_system_graphs=True,
diff --git a/tests/fixtures/ontology.ttl b/tests/fixtures/ontology.ttl
new file mode 100644
index 0000000..7f138f0
--- /dev/null
+++ b/tests/fixtures/ontology.ttl
@@ -0,0 +1,10 @@
+@prefix owl: .
+@prefix rdfs: .
+
+
+ a owl:Ontology ;
+ rdfs:label "Ontology for Persons" .
+
+
+ a owl:Class ;
+ rdfs:label "Person" .
diff --git a/tests/test_validate_graph.py b/tests/test_validate_graph.py
index 89d8419..29698cb 100644
--- a/tests/test_validate_graph.py
+++ b/tests/test_validate_graph.py
@@ -13,13 +13,19 @@
from cmem_client.repositories.graphs import GraphExportConfig, GraphsRepository
from cmem_client.repositories.protocols.import_item import ImportConflictPolicy
from cmem_plugin_base.dataintegration.entity import Entities
-from cmem_plugin_base.testing import TestExecutionContext
+from cmem_plugin_base.dataintegration.parameter.graph import GraphParameterType
+from cmem_plugin_base.testing import TestExecutionContext, TestPluginContext
-from cmem_plugin_validation.validate_graph.task import ValidateGraph
+from cmem_plugin_validation.validate_graph.task import CONTEXT_GRAPH_CLASSES, ValidateGraph
from tests.fixtures import FIXTURE_DIR
N_TRIPLES = GraphExportConfig(serialization=GraphsRepository.formats["n-triples"])
+needs_cmem = pytest.mark.skipif(
+ environ.get("CMEM_BASE_URI", "") == "",
+ reason="Needs eccenca Corporate Memory configuration",
+)
+
def get_client() -> Client:
"""Get a fresh client
@@ -60,6 +66,8 @@ class TestSetup:
shapes_graph = "http://docker.localhost/shapes-for-persons/"
shapes_file = FIXTURE_DIR / "shapes.ttl"
result_graph = "http://docker.localhost/results/"
+ ontology_graph = "http://docker.localhost/ontology-for-persons/"
+ ontology_file = FIXTURE_DIR / "ontology.ttl"
@pytest.fixture
@@ -77,6 +85,18 @@ def test_setup() -> Generator[TestSetup, Any]:
_delete_graphs(_.persons_graph, _.shapes_graph, _.result_graph)
+@pytest.fixture
+def ontology_graph() -> Generator[str, Any]:
+ """Provide a graph which is typed as an owl:Ontology"""
+ _ = TestSetup()
+ client = get_client()
+ client.graphs.import_item(
+ path=_.ontology_file, key=_.ontology_graph, on_conflict=ImportConflictPolicy.REPLACE
+ )
+ yield _.ontology_graph
+ _delete_graphs(_.ontology_graph)
+
+
def test_fails(test_setup: TestSetup) -> None:
"""Test failing task execution"""
_ = test_setup
@@ -165,3 +185,22 @@ def test_different_query(test_setup: TestSetup) -> None:
assert task.execute(context=TestExecutionContext(), inputs=[]) is None, (
"Should no violations, since no person was validated"
)
+
+
+@needs_cmem
+def test_ontology_as_context_graph(ontology_graph: str) -> None:
+ """Test that an ontology graph is offered as a context graph"""
+ parameter_type = GraphParameterType(
+ classes=CONTEXT_GRAPH_CLASSES,
+ show_di_graphs=False,
+ show_graphs_without_class=True,
+ show_system_graphs=True,
+ allow_only_autocompleted_values=False,
+ )
+ values = {
+ _.value
+ for _ in parameter_type.autocomplete(
+ query_terms=[], depend_on_parameter_values=[], context=TestPluginContext()
+ )
+ }
+ assert ontology_graph in values