Пример #1
0
def test_dependency_parserset_merge(clear_graph, graph):
    """
    Test data loading functionality for two parsers that depend on each other.
    """
    root_parser = RootTestParser()
    depending_parser = DependingTestParser()

    ps = ParserSet()
    ps.parsers.append(root_parser)
    ps.parsers.append(depending_parser)

    ps.run_and_merge(graph)

    result = graph.run(
        "MATCH (s:Source) RETURN count(distinct s) AS count").data()
    assert result[0]['count'] == len(root_parser.source.nodes)

    result = graph.run(
        "MATCH (t:Target) RETURN count(distinct t) AS count").data()
    assert result[0]['count'] == len(root_parser.target.nodes)

    result = graph.run(
        "MATCH (s:Source)-[r:FOO]->(t:Target) RETURN count(distinct r) AS count"
    ).data()
    assert result[0]['count'] == len(depending_parser.rels.relationships)

    ps.run_and_merge(graph)

    result = graph.run(
        "MATCH (s:Source) RETURN count(distinct s) AS count").data()
    assert result[0]['count'] == len(root_parser.source.nodes)

    result = graph.run(
        "MATCH (t:Target) RETURN count(distinct t) AS count").data()
    assert result[0]['count'] == len(root_parser.target.nodes)

    result = graph.run(
        "MATCH (s:Source)-[r:FOO]->(t:Target) RETURN count(distinct r) AS count"
    ).data()
    assert result[0]['count'] == len(depending_parser.rels.relationships)
Пример #2
0
def test_parserset_merge(clear_graph, tmp_path, graph):
    """
    Use the TestParser, run_and_merge it, count graph elements. Merge again, count again.
    """
    some_parser = SomeTestParser()
    ps = ParserSet()
    ps.parsers.append(some_parser)

    ps.run_and_merge(graph)

    result = graph.run(
        "MATCH (s:Source) RETURN count(distinct s) AS count").data()
    assert result[0]['count'] == len(some_parser.source.nodes)

    result = graph.run(
        "MATCH (t:Target) RETURN count(distinct t) AS count").data()
    assert result[0]['count'] == len(some_parser.target.nodes)

    result = graph.run(
        "MATCH (s:Source)-[r:FOO]->(t:Target) RETURN count(distinct r) AS count"
    ).data()
    assert result[0]['count'] == len(some_parser.rels.relationships)

    ps.run_and_merge(graph)

    result = graph.run(
        "MATCH (s:Source) RETURN count(distinct s) AS count").data()
    assert result[0]['count'] == len(some_parser.source.nodes)

    result = graph.run(
        "MATCH (t:Target) RETURN count(distinct t) AS count").data()
    assert result[0]['count'] == len(some_parser.target.nodes)

    result = graph.run(
        "MATCH (s:Source)-[r:FOO]->(t:Target) RETURN count(distinct r) AS count"
    ).data()
    assert result[0]['count'] == len(some_parser.rels.relationships)