diff --git a/case_utils/case_sparql_construct/__init__.py b/case_utils/case_sparql_construct/__init__.py index 0a77e4e..4eaeceb 100644 --- a/case_utils/case_sparql_construct/__init__.py +++ b/case_utils/case_sparql_construct/__init__.py @@ -78,7 +78,7 @@ def main(): "format": output_format } if output_format == "json-ld": - context_dictionary = {k:v for (k,v) in graph.namespace_manager.namespaces()} + context_dictionary = {k:v for (k,v) in out_graph.namespace_manager.namespaces()} serialize_kwargs["context"] = context_dictionary out_graph.serialize(args.out_graph, **serialize_kwargs) diff --git a/tests/case_sparql_construct/.gitignore b/tests/case_sparql_construct/.gitignore index 1f24ccd..6553b72 100644 --- a/tests/case_sparql_construct/.gitignore +++ b/tests/case_sparql_construct/.gitignore @@ -1 +1,2 @@ +output.json output.ttl diff --git a/tests/case_sparql_construct/Makefile b/tests/case_sparql_construct/Makefile index 911a19c..55343fc 100644 --- a/tests/case_sparql_construct/Makefile +++ b/tests/case_sparql_construct/Makefile @@ -21,6 +21,7 @@ all: \ output.ttl check: \ + output.json \ output.ttl source $(tests_srcdir)/venv/bin/activate \ && pytest \ @@ -30,10 +31,10 @@ clean: @rm -rf \ __pycache__ @rm -f \ - output.ttl \ + output.* \ _* -output.ttl: \ +output.%: \ $(tests_srcdir)/.venv.done.log \ $(top_srcdir)/case_utils/case_sparql_construct/__init__.py \ input-1.sparql \ diff --git a/tests/case_sparql_construct/test_case_sparql_construct.py b/tests/case_sparql_construct/test_case_sparql_construct.py index 60da9d9..9eb2002 100644 --- a/tests/case_sparql_construct/test_case_sparql_construct.py +++ b/tests/case_sparql_construct/test_case_sparql_construct.py @@ -15,7 +15,7 @@ import case_utils -def test_templates_with_blank_nodes_result(): +def _test_templates_with_blank_nodes_result(filename): ground_truth_positive = { ("Alice", "Hacker"), ("Bob", "Hacker") @@ -23,7 +23,7 @@ def test_templates_with_blank_nodes_result(): ground_truth_negative = set() graph = rdflib.Graph() - graph.parse("output.ttl", format=case_utils.guess_format("output.ttl")) + graph.parse(filename, format=case_utils.guess_format(filename)) computed = set() query_string = """\ @@ -47,3 +47,8 @@ def test_templates_with_blank_nodes_result(): l_family_name.toPython() )) assert computed == ground_truth_positive + +def test_templates_with_blank_nodes_result_json(): + _test_templates_with_blank_nodes_result("output.json") +def test_templates_with_blank_nodes_result_turtle(): + _test_templates_with_blank_nodes_result("output.ttl")