| | |
| | import requests |
| |
|
| | BASE_URL = "http://localhost:5000" |
| |
|
| | def test_load_graph(): |
| | print("\n--- Testing Graph Loading ---") |
| | response = requests.post(f"{BASE_URL}/load_graph") |
| | print("Load Graph Response:", response.json()) |
| |
|
| | def test_create_node(): |
| | print("\n--- Testing Node Creation ---") |
| | data = { |
| | "node_id": "patient_123", |
| | "data": { |
| | "name": "John Doe", |
| | "age": 45, |
| | "medical_conditions": ["hypertension", "diabetes"] |
| | }, |
| | "domain": "Healthcare", |
| | "type": "Patient" |
| | } |
| | response = requests.post(f"{BASE_URL}/create_node", json=data) |
| | print("Create Node Response:", response.json()) |
| |
|
| | def test_query_node(node_id): |
| | print(f"\n--- Testing Node Query ({node_id}) ---") |
| | response = requests.get(f"{BASE_URL}/query_node", params={"node_id": node_id}) |
| | print(f"Query Node {node_id} Response:", response.json()) |
| |
|
| | def test_list_nodes(): |
| | print("\n--- Testing List All Nodes ---") |
| | response = requests.get(f"{BASE_URL}/list_nodes") |
| | print("List Nodes Response:", response.json()) |
| |
|
| | def test_list_relationships(): |
| | print("\n--- Testing List All Relationships ---") |
| | response = requests.get(f"{BASE_URL}/list_relationships") |
| | print("List Relationships Response:", response.json()) |
| |
|
| | def test_traverse_node(node_id, direction): |
| | print(f"\n--- Testing Node Traversal ({node_id}, {direction}) ---") |
| | response = requests.get(f"{BASE_URL}/traverse_node", params={"node_id": node_id, "direction": direction}) |
| | print(f"Traversal Path ({node_id} - {direction}):", response.json()) |
| |
|
| | def test_inspect_relationships(node_id): |
| | print(f"\n--- Testing Inspect Relationships for Node ({node_id}) ---") |
| | response = requests.get(f"{BASE_URL}/inspect_relationships", params={"node_id": node_id}) |
| | print(f"Inspect Relationships for {node_id}:", response.json()) |
| |
|
| | if __name__ == "__main__": |
| | |
| | test_load_graph() |
| |
|
| | |
| | test_create_node() |
| |
|
| | |
| | test_query_node("patient_123") |
| | test_query_node("Healthcare") |
| |
|
| | |
| | test_list_nodes() |
| |
|
| | |
| | test_list_relationships() |
| |
|
| | |
| | test_traverse_node("patient_123", "up") |
| | test_traverse_node("Healthcare", "down") |
| |
|
| | |
| | test_inspect_relationships("Healthcare") |
| | test_inspect_relationships("patient_123") |