Skip to content

Commit 09468f0

Browse files
Merge pull request #8 from casework/AC-178
Add JSON-LD output code path test for case_sparql_construct
2 parents 8f26896 + 337ae08 commit 09468f0

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

case_utils/case_sparql_construct/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def main():
7878
"format": output_format
7979
}
8080
if output_format == "json-ld":
81-
context_dictionary = {k:v for (k,v) in graph.namespace_manager.namespaces()}
81+
context_dictionary = {k:v for (k,v) in out_graph.namespace_manager.namespaces()}
8282
serialize_kwargs["context"] = context_dictionary
8383

8484
out_graph.serialize(args.out_graph, **serialize_kwargs)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
output.json
12
output.ttl

tests/case_sparql_construct/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ all: \
2121
output.ttl
2222

2323
check: \
24+
output.json \
2425
output.ttl
2526
source $(tests_srcdir)/venv/bin/activate \
2627
&& pytest \
@@ -30,10 +31,10 @@ clean:
3031
@rm -rf \
3132
__pycache__
3233
@rm -f \
33-
output.ttl \
34+
output.* \
3435
_*
3536

36-
output.ttl: \
37+
output.%: \
3738
$(tests_srcdir)/.venv.done.log \
3839
$(top_srcdir)/case_utils/case_sparql_construct/__init__.py \
3940
input-1.sparql \

tests/case_sparql_construct/test_case_sparql_construct.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
import case_utils
1717

18-
def test_templates_with_blank_nodes_result():
18+
def _test_templates_with_blank_nodes_result(filename):
1919
ground_truth_positive = {
2020
("Alice", "Hacker"),
2121
("Bob", "Hacker")
2222
}
2323
ground_truth_negative = set()
2424

2525
graph = rdflib.Graph()
26-
graph.parse("output.ttl", format=case_utils.guess_format("output.ttl"))
26+
graph.parse(filename, format=case_utils.guess_format(filename))
2727

2828
computed = set()
2929
query_string = """\
@@ -47,3 +47,8 @@ def test_templates_with_blank_nodes_result():
4747
l_family_name.toPython()
4848
))
4949
assert computed == ground_truth_positive
50+
51+
def test_templates_with_blank_nodes_result_json():
52+
_test_templates_with_blank_nodes_result("output.json")
53+
def test_templates_with_blank_nodes_result_turtle():
54+
_test_templates_with_blank_nodes_result("output.ttl")

0 commit comments

Comments
 (0)