yangdx commited on
Commit
919fe2d
·
1 Parent(s): 8eb5fb6

Fix graph unit test edge direction problem

Browse files
Files changed (1) hide show
  1. tests/test_graph_storage.py +17 -8
tests/test_graph_storage.py CHANGED
@@ -744,16 +744,25 @@ async def test_graph_batch_operations(storage):
744
  print(f"节点 {node3_id} 的出边: {node3_outgoing_edges}")
745
  print(f"节点 {node3_id} 的入边: {node3_incoming_edges}")
746
 
747
- # 检查是否包含从机器学习来的边,以及到自然语言处理和计算机视觉的边
748
- has_edge_from_node2 = any(src == node2_id for src, _ in node3_incoming_edges)
749
- has_edge_to_node4 = any(tgt == node4_id for _, tgt in node3_outgoing_edges)
750
- has_edge_to_node5 = any(tgt == node5_id for _, tgt in node3_outgoing_edges)
 
 
 
 
 
 
 
 
 
751
 
752
  assert (
753
- has_edge_from_node2
754
- ), f"节点 {node3_id} 的边列表中应包含从 {node2_id} 来的边"
755
- assert has_edge_to_node4, f"节点 {node3_id} 的边列表中应包含到 {node4_id} 的边"
756
- assert has_edge_to_node5, f"节点 {node3_id} 的边列表中应包含到 {node5_id} 的边"
757
 
758
  print("无向图特性验证成功:批量获取的节点边包含所有相关的边(无论方向)")
759
 
 
744
  print(f"节点 {node3_id} 的出边: {node3_outgoing_edges}")
745
  print(f"节点 {node3_id} 的入边: {node3_incoming_edges}")
746
 
747
+ # 检查是否包含与机器学习、自然语言处理和计算机视觉的连接(忽略方向)
748
+ has_connection_with_node2 = any(
749
+ (src == node2_id and tgt == node3_id) or (src == node3_id and tgt == node2_id)
750
+ for src, tgt in nodes_edges[node3_id]
751
+ )
752
+ has_connection_with_node4 = any(
753
+ (src == node3_id and tgt == node4_id) or (src == node4_id and tgt == node3_id)
754
+ for src, tgt in nodes_edges[node3_id]
755
+ )
756
+ has_connection_with_node5 = any(
757
+ (src == node3_id and tgt == node5_id) or (src == node5_id and tgt == node3_id)
758
+ for src, tgt in nodes_edges[node3_id]
759
+ )
760
 
761
  assert (
762
+ has_connection_with_node2
763
+ ), f"节点 {node3_id} 的边列表中应包含与 {node2_id} 的连接"
764
+ assert has_connection_with_node4, f"节点 {node3_id} 的边列表中应包含与 {node4_id} 的连接"
765
+ assert has_connection_with_node5, f"节点 {node3_id} 的边列表中应包含与 {node5_id} 的连接"
766
 
767
  print("无向图特性验证成功:批量获取的节点边包含所有相关的边(无论方向)")
768