From bee51bb4d128fd37a5d2380d7a25a89a126dc713 Mon Sep 17 00:00:00 2001 From: Julian Minder Date: Tue, 9 Apr 2024 00:51:39 +0200 Subject: [PATCH] Fixed issue in test, fixes #21 --- rel2graph/neo4j/__init__.py | 3 +-- tests/unit/neo4j/test_match.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/rel2graph/neo4j/__init__.py b/rel2graph/neo4j/__init__.py index d225c45..1cabe1e 100644 --- a/rel2graph/neo4j/__init__.py +++ b/rel2graph/neo4j/__init__.py @@ -68,7 +68,7 @@ def match_nodes(session: Session, *labels: List[str], **properties: dict): unwind = "UNWIND $data as r" if len(data) > 0 else "" clause = cypher_join(unwind, _match_clause('n', tuple(flat_params), "r"), "RETURN n, LABELS(n), ID(n)", data=data) - print(clause) + records = session.run(*clause).data() # Convert to Node out = [] @@ -115,7 +115,6 @@ def match_relationships(session: Session, from_node: Node =None, to_node:Node =N " AND ".join(clauses), "RETURN PROPERTIES(r), TYPE(r), ID(r), from_node, LABELS(from_node), ID(from_node), to_node, LABELS(to_node), ID(to_node)" ) - records = session.run(*clause).data() out = [] for record in records: diff --git a/tests/unit/neo4j/test_match.py b/tests/unit/neo4j/test_match.py index c52aece..d4f5521 100644 --- a/tests/unit/neo4j/test_match.py +++ b/tests/unit/neo4j/test_match.py @@ -33,7 +33,7 @@ def session(): n3 = Node("anotherlabel", id=3, name="test3") r1 = Relationship(n1, "to", n2, id=1) - r2 = Relationship(n1, "to", n3, id=2, name="test") + r2 = Relationship(n1, "to", n3, id=2, anotherattr="test") graph = n1 | n2 | n3 | r1 | r2 create(graph, session) @@ -92,9 +92,9 @@ def test_match_relationships(session): assert(check_rel(rels, 1)) # match by multiple properties - rels = match_relationships(session, rel_type="to", id=1, name="test") + rels = match_relationships(session, rel_type="to", id=2, anotherattr="test") assert(len(rels) == 1) - assert(check_rel(rels, 1)) + assert(check_rel(rels,2)) # match by from node n1 = match_nodes(session, "test", id=1)[0]