MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_path_comparison

Method test_path_comparison

tests/flow/test_path.py:172–208  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

170 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
171
172 def test_path_comparison(self):
173 node0 = Node(node_id=0, label="L1")
174 node1 = Node(node_id=1, label="L1")
175 node2 = Node(node_id=2, label="L1")
176 edge01 = Edge(node0, "R1", node1, edge_id=0, properties={'value': 1})
177 edge12 = Edge(node1, "R1", node2, edge_id=1, properties={'value': 2})
178
179 redis_graph.add_node(node0)
180 redis_graph.add_node(node1)
181 redis_graph.add_node(node2)
182 redis_graph.add_edge(edge01)
183 redis_graph.add_edge(edge12)
184
185 redis_graph.flush()
186
187 # Rewrite the edges with IDs instead of node values to match how they are returned.
188 edge01 = Edge(0, "R1", 1, edge_id=0, properties={'value': 1})
189 edge12 = Edge(1, "R1", 2, edge_id=1, properties={'value': 2})
190
191 path01 = Path.new_empty_path().add_node(node0).add_edge(edge01).add_node(node1)
192 path12 = Path.new_empty_path().add_node(node1).add_edge(edge12).add_node(node2)
193
194 # Test a path equality filter
195 query = "MATCH p1 = (:L1)-[:R1]->(:L1) MATCH p2 = (:L1)-[:R1]->(:L1) WHERE p1 = p2 RETURN p1"
196 expected_results = [[path01],
197 [path12]]
198
199 query_info = QueryInfo(query=query, description="Test path equality", expected_result=expected_results)
200 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
201
202 # Test a path inequality filter
203 query = "MATCH p1 = (:L1)-[:R1]->(:L1) MATCH p2 = (:L1)-[:R1]->(:L1) WHERE p1 <> p2 RETURN DISTINCT p1, p2"
204 expected_results = [[path01, path12],
205 [path12, path01]]
206
207 query_info = QueryInfo(query=query, description="Test path inequality", expected_result=expected_results)
208 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
209
210 # Test property accesses against non-identifier entities.
211 def test_path_property_access(self):

Callers

nothing calls this directly

Calls 5

QueryInfoClass · 0.90
NodeClass · 0.50
EdgeClass · 0.50
queryMethod · 0.45

Tested by

no test coverage detected