Singularity / scripts /dev /1_test_node_creation.py
SlappAI's picture
dev scripts
64ed965
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()