Ejemplo n.º 1
0
def _test_parser(jsonpath, turtlepath):
    test_tree, test_graph = _load_test_data(jsonpath, turtlepath)
    graph = to_rdf(test_tree, Graph())
    assert isomorphic(graph, test_graph), \
            "Expected graph:\n%s\nGot:\n %s" % (
                    test_graph.serialize(format='n3'),
                    graph.serialize(format='n3'))
Ejemplo n.º 2
0
def _test_parser(jsonpath, turtlepath):
    test_tree, test_graph = _load_test_data(jsonpath, turtlepath)
    graph = to_rdf(test_tree, Graph())
    assert isomorphic(graph, test_graph), \
            "Expected graph:\n%s\nGot:\n %s" % (
                    test_graph.serialize(format='n3'),
                    graph.serialize(format='n3'))
Ejemplo n.º 3
0
 def test03(self):
     ingraph = to_rdf(json.loads(test03_in), ConjunctiveGraph())
     outgraph = ConjunctiveGraph().parse(
         data=ingraph.serialize(format="xml"), format="xml")
     assert isomorphic(outgraph, ingraph), \
             "Expected graph of %s:\n%s\nGot graph of %s:\n %s" % (
                     len(outgraph), outgraph.serialize(),
                     len(ingraph), ingraph.serialize())
Ejemplo n.º 4
0
 def test03(self):
     ingraph = to_rdf(json.loads(test03_in), ConjunctiveGraph())
     outgraph = ConjunctiveGraph().parse(
         data=ingraph.serialize(format="xml"), format="xml")
     assert isomorphic(outgraph, ingraph), \
             "Expected graph of %s:\n%s\nGot graph of %s:\n %s" % (
                     len(outgraph), outgraph.serialize(),
                     len(ingraph), ingraph.serialize())
Ejemplo n.º 5
0
 def test01(self):
     # tree, graph, base=None, context_data=None
     g = ConjunctiveGraph()
     ingraph = to_rdf(json.loads(test01_in), g)
     outgraph = ConjunctiveGraph()
     outgraph.parse(data=test01_out, format="nquads")
     assert isomorphic(outgraph, ingraph), \
             "Expected graph of %s:\n%s\nGot graph of %s:\n %s" % (
                     len(outgraph), outgraph.serialize(),
                     len(ingraph), ingraph.serialize())
Ejemplo n.º 6
0
 def test01(self):
     # tree, graph, base=None, context_data=None
     g = ConjunctiveGraph()
     ingraph = to_rdf(json.loads(test01_in), g)
     outgraph = ConjunctiveGraph()
     outgraph.parse(data=test01_out, format="nquads")
     assert isomorphic(outgraph, ingraph), \
             "Expected graph of %s:\n%s\nGot graph of %s:\n %s" % (
                     len(outgraph), outgraph.serialize(),
                     len(ingraph), ingraph.serialize())
Ejemplo n.º 7
0
def _test_parser(inputpath, expectedpath, context):
    input_tree = _load_json(inputpath)
    expected_graph = _load_nquads(expectedpath)
    base = TC_BASE + inputpath
    result_graph = to_rdf(
        input_tree, ConjunctiveGraph(),
        base=base, context_data=context)
    assert isomorphic(
        result_graph, expected_graph), "Expected:\n%s\nGot:\n%s" % (
            expected_graph.serialize(format='n3'),
            result_graph.serialize(format='n3'))
Ejemplo n.º 8
0
def _test_parser(inputpath, expectedpath, context, serpar):
    test_tree, test_graph = _load_test_data(inputpath, expectedpath, context)
    if isinstance(test_tree, ConjunctiveGraph):
        graph = test_tree
    else:
        g = ConjunctiveGraph()
        result = to_rdf(test_tree, g, context_data=context)
    if test_graph is not None:
        assert isomorphic(result, test_graph), \
            "Expected:\n%s\nGot:\n%s" % (
                test_graph.serialize(format='n3'),
                result.serialize(format='n3'))
        # assert isomorphic(graph, test_graph), \
        #         "Mismatch of expected graph vs result"
    else:
        graph_json = graph.serialize(format="json-ld", context=context)
        expected_json = open(expectedpath, 'rb').read()
        assert jsonld_compare(graph_json, expected_json) == True, \
                "Expected JSON:\n%s\nGot:\n %s" % (expected_json, graph_json)
Ejemplo n.º 9
0
def _test_parser(inputpath, expectedpath, context, serpar):
    test_tree, test_graph = _load_test_data(inputpath, expectedpath, context)
    if isinstance(test_tree, ConjunctiveGraph):
        graph = test_tree
    else:
        g = ConjunctiveGraph()
        result = to_rdf(test_tree, g, context_data=context)
    if test_graph is not None:
        assert isomorphic(result, test_graph), \
            "Expected:\n%s\nGot:\n%s" % (
                test_graph.serialize(format='n3'),
                result.serialize(format='n3'))
        # assert isomorphic(graph, test_graph), \
        #         "Mismatch of expected graph vs result"
    else:
        graph_json = graph.serialize(format="json-ld", context=context)
        expected_json = open(expectedpath, 'rb').read()
        assert jsonld_compare(graph_json, expected_json) == True, \
                "Expected JSON:\n%s\nGot:\n %s" % (expected_json, graph_json)