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

Method test_bi_directional_path_functions

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

Source from the content-addressed store, hash-verified

116 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
117
118 def test_bi_directional_path_functions(self):
119 node0 = Node(node_id=0, label="L1")
120 node1 = Node(node_id=1, label="L1")
121 node2 = Node(node_id=2, label="L1")
122 edge01 = Edge(node0, "R1", node1, edge_id=0, properties={'value': 1})
123 edge12 = Edge(node1, "R1", node2, edge_id=1, properties={'value': 2})
124
125 redis_graph.add_node(node0)
126 redis_graph.add_node(node1)
127 redis_graph.add_node(node2)
128 redis_graph.add_edge(edge01)
129 redis_graph.add_edge(edge12)
130
131 redis_graph.flush()
132
133 # Rewrite the edges with IDs instead of node values to match how they are returned.
134 edge01 = Edge(0, "R1", 1, edge_id=0, properties={'value': 1})
135 edge12 = Edge(1, "R1", 2, edge_id=1, properties={'value': 2})
136 # Reverse direction edges which are not part of the graph. Read only values.
137 edge10 = Edge(1, "R1", 0, edge_id = 0 , properties={'value':1})
138 edge21 = Edge(2, "R1", 1, edge_id = 1 , properties={'value':2})
139
140 expected_results=[[[node0, node1, node0], [edge01, edge10], 2],
141 [[node0, node1, node2, node1], [edge01, edge12, edge21], 3],
142 [[node0, node1, node2, node1, node0], [edge01, edge12, edge21, edge10], 4],
143 [[node1, node2, node1], [edge12, edge21], 2],
144 [[node1, node2, node1, node0], [edge12, edge21, edge10], 3]]
145
146 query = "MATCH p=(:L1)-[:R1*]->(:L1)<-[:R1*]-() RETURN nodes(p), relationships(p), length(p)"
147
148 query_info = QueryInfo(query = query, description="Tests path functions over bi directional variable length paths", \
149 expected_result = expected_results)
150 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
151
152 def test_zero_length_path(self):
153 node0 = Node(node_id=0, label="L1")

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