-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ai_generation.py
More file actions
41 lines (31 loc) · 1.29 KB
/
test_ai_generation.py
File metadata and controls
41 lines (31 loc) · 1.29 KB
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
import sys
import os
import json
# Add backend to path
sys.path.append(os.path.join(os.getcwd(), 'backend'))
from app.services.ai_service import generate_diagram_from_prompt
def test_ai_generation():
prompt = "A food delivery app with real-time tracking, payments, and search."
print(f"Testing Prompt: '{prompt}'")
diagram = generate_diagram_from_prompt(prompt, "mobile")
print(f"Generated {len(diagram.nodes)} nodes and {len(diagram.edges)} edges.")
node_types = [n.data['type'] for n in diagram.nodes]
print("Node Types:", node_types)
# Assertions
required_types = ["Mobile App", "API Gateway", "Microservice", "Database"]
for rt in required_types:
if rt in node_types:
print(f"PASS: Found {rt}")
else:
print(f"FAIL: Missing {rt}")
# Check specific heuristics
if "Payment Service" in [n.data['label'] for n in diagram.nodes]:
print("PASS: Found Payment Service (from 'payments' keyword)")
else:
print("FAIL: Missing Payment Service")
if "Redis Cache" in [n.data['label'] for n in diagram.nodes]:
print("PASS: Found Redis Cache (from 'real-time' keyword)")
else:
print("FAIL: Missing Redis Cache")
if __name__ == "__main__":
test_ai_generation()