1+ import itertools
12import logging
23from test .data import TEST_DATA_DIR
34from test .utils import GraphHelper
4- from test .utils .graph import load_sources
5+ from test .utils .graph import GraphSource
56from test .utils .namespace import EGDO
67from typing import Callable
78
1011from rdflib .graph import ConjunctiveGraph , Dataset , Graph
1112
1213
13- @pytest .mark .parametrize ("graph_factory" , [Graph , ConjunctiveGraph , Dataset ])
14- def test_load_into_default (graph_factory : Callable [[], Graph ]) -> None :
14+ @pytest .mark .parametrize (
15+ ("graph_factory" , "source" ),
16+ itertools .product (
17+ [Graph , ConjunctiveGraph , Dataset ],
18+ GraphSource .from_paths (
19+ TEST_DATA_DIR / "variants" / "simple_triple.ttl" ,
20+ TEST_DATA_DIR / "variants" / "relative_triple.ttl" ,
21+ ),
22+ ),
23+ ids = GraphSource .idfn ,
24+ )
25+ def test_load_into_default (
26+ graph_factory : Callable [[], Graph ], source : GraphSource
27+ ) -> None :
1528 """
1629 Evaluation of ``LOAD <source>`` into default graph works correctly.
1730 """
18- source_path = TEST_DATA_DIR / "variants" / "simple_triple.ttl"
1931
2032 expected_graph = graph_factory ()
21- load_sources ( source_path , graph = expected_graph )
33+ source . load ( graph = expected_graph )
2234
2335 actual_graph = graph_factory ()
24- actual_graph .update (f"LOAD <{ source_path . as_uri ()} >" )
36+ actual_graph .update (f"LOAD <{ source . public_id_or_path_uri ()} >" )
2537
2638 if logging .getLogger ().isEnabledFor (logging .DEBUG ):
2739 debug_format = (
28- "trig " if isinstance (expected_graph , ConjunctiveGraph ) else "turtle "
40+ "nquads " if isinstance (expected_graph , ConjunctiveGraph ) else "ntriples "
2941 )
3042 logging .debug (
3143 "expected_graph = \n %s" , expected_graph .serialize (format = debug_format )
@@ -41,22 +53,35 @@ def test_load_into_default(graph_factory: Callable[[], Graph]) -> None:
4153 GraphHelper .assert_triple_sets_equals (expected_graph , actual_graph )
4254
4355
44- @pytest .mark .parametrize ("graph_factory" , [ConjunctiveGraph , Dataset ])
45- def test_load_into_named (graph_factory : Callable [[], ConjunctiveGraph ]) -> None :
56+ @pytest .mark .parametrize (
57+ ("graph_factory" , "source" ),
58+ itertools .product (
59+ [ConjunctiveGraph , Dataset ],
60+ GraphSource .from_paths (
61+ TEST_DATA_DIR / "variants" / "simple_triple.ttl" ,
62+ TEST_DATA_DIR / "variants" / "relative_triple.ttl" ,
63+ ),
64+ ),
65+ ids = GraphSource .idfn ,
66+ )
67+ def test_load_into_named (
68+ graph_factory : Callable [[], ConjunctiveGraph ], source : GraphSource
69+ ) -> None :
4670 """
4771 Evaluation of ``LOAD <source> INTO GRAPH <name>`` works correctly.
4872 """
49- source_path = TEST_DATA_DIR / "variants" / "simple_triple.ttl"
5073
5174 expected_graph = graph_factory ()
52- load_sources ( source_path , graph = expected_graph .get_context (EGDO .graph ))
75+ source . load ( graph = expected_graph .get_context (EGDO .graph ))
5376
5477 actual_graph = graph_factory ()
5578
56- actual_graph .update (f"LOAD <{ source_path .as_uri ()} > INTO GRAPH <{ EGDO .graph } >" )
79+ actual_graph .update (
80+ f"LOAD <{ source .public_id_or_path_uri ()} > INTO GRAPH <{ EGDO .graph } >"
81+ )
5782
5883 if logging .getLogger ().isEnabledFor (logging .DEBUG ):
59- debug_format = "trig "
84+ debug_format = "nquads "
6085 logging .debug (
6186 "expected_graph = \n %s" , expected_graph .serialize (format = debug_format )
6287 )
0 commit comments