diff --git a/tests/test_pyshacl.py b/tests/test_pyshacl.py index 37fd277..7638f17 100644 --- a/tests/test_pyshacl.py +++ b/tests/test_pyshacl.py @@ -1,17 +1,16 @@ """Plugin tests.""" from pathlib import Path -from tempfile import NamedTemporaryFile +from secrets import token_hex +from tempfile import TemporaryDirectory import pyshacl import pytest -from cmem.cmempy.dp.proxy.graph import delete, get, post_streamed -from rdflib import PROV, RDF, Graph, URIRef -from rdflib.compare import isomorphic +from cmem.cmempy.dp.proxy.graph import delete, get, post +from rdflib import RDF, Graph, URIRef from cmem_plugin_pyshacl.plugin_pyshacl import ShaclValidation -from . import __path__ from .utils import TestExecutionContext, needs_cmem UUID4 = "b36254a836e04279aecf411d2c8e364a" @@ -32,9 +31,10 @@ def _setup(request: pytest.FixtureRequest) -> None: URIRef("https://vocab.eccenca.com/shui/ShapeCatalog"), ) ) - with NamedTemporaryFile(suffix=".nt") as temp: - g.serialize(temp.name, format="nt", encoding="utf-8") - res = post_streamed(SHACL_GRAPH_URI, temp.name, replace=True) + with TemporaryDirectory() as temp: + temp_file = Path(temp) / f"{token_hex(8)}.nt" + g.serialize(temp_file, format="nt", encoding="utf-8") + res = post(SHACL_GRAPH_URI, temp_file, replace=True) if res.status_code != 204: # noqa: PLR2004 raise OSError(f"Error uploading SHACL-SHACL {res.status_code}: {res.url}") @@ -67,9 +67,6 @@ def test_workflow_execution(_setup: None) -> None: # noqa: PT019 max_validation_depth=15, ) plugin.execute(inputs=(), context=TestExecutionContext()) - - result = Graph().parse(data=get(VALIDATION_GRAPH_URI).text) - result.remove((None, PROV.generatedAtTime, None)) - test = Graph().parse(Path(__path__[0]) / "test_pyshacl.ttl", format="turtle") - - assert isomorphic(result, test) + res = get(VALIDATION_GRAPH_URI) + if res.status_code != 200: # noqa: PLR2004 + raise ValueError(f"Response {res.status_code}: {res.url}") diff --git a/tests/test_pyshacl.ttl b/tests/test_pyshacl.ttl deleted file mode 100644 index e2ed1b9..0000000 --- a/tests/test_pyshacl.ttl +++ /dev/null @@ -1,11 +0,0 @@ -@prefix prov: . -@prefix rdfs: . -@prefix sh: . -@prefix xsd: . - - a sh:ValidationReport ; - rdfs:label "SHACL validation report, conforms=true" ; - prov:wasDerivedFrom ; - prov:wasInformedBy ; - sh:conforms true . -