File size: 1,535 Bytes
64ed965 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import requests
import json
BASE_URL = "http://localhost:5000"
def test_load_graph():
response = requests.post(f"{BASE_URL}/load_graph")
print("Load Graph Response:", response.json())
def test_create_node():
payload = {
"node_id": "patient_123",
"data": {
"name": "John Doe",
"age": 45,
"medical_conditions": ["hypertension", "diabetes"]
},
"domain": "Healthcare",
"type": "Patient"
}
headers = {"Content-Type": "application/json"}
response = requests.post(f"{BASE_URL}/create_node", headers=headers, data=json.dumps(payload))
print("Create Node Response:", response.json())
def test_query_node(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():
response = requests.get(f"{BASE_URL}/list_nodes")
print("List Nodes Response:", response.json())
def test_list_relationships():
response = requests.get(f"{BASE_URL}/list_relationships")
print("List Relationships Response:", response.json())
if __name__ == "__main__":
print("\n--- Testing Graph Loading ---")
test_load_graph()
print("\n--- Testing Node Creation ---")
test_create_node()
print("\n--- Testing Node Query ---")
test_query_node("patient_123")
print("\n--- Testing List All Nodes ---")
test_list_nodes()
print("\n--- Testing List All Relationships ---")
test_list_relationships() |