-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
77 lines (60 loc) · 1.89 KB
/
Copy pathtest_app.py
File metadata and controls
77 lines (60 loc) · 1.89 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
"""
Test application for AIVory Monitor breakpoint testing.
Run this app, then set breakpoints in the IDE on the functions below.
"""
import sys
import time
import random
sys.path.insert(0, '.')
import aivory_monitor
# Initialize agent
aivory_monitor.init(
api_key='aiv_mon_ae6dba5c7b6647c58eb1f27c',
backend_url='ws://localhost:8080/ws/monitor/agent',
environment='development',
debug=True,
)
print("\n" + "="*60)
print("AIVory Monitor Test App - Set breakpoints on these functions:")
print(" - process_user() line 35")
print(" - calculate_total() line 45")
print(" - fetch_data() line 55")
print("Press Ctrl+C to stop.")
print("="*60 + "\n")
time.sleep(2)
def process_user(user_id: int) -> dict:
"""Set breakpoint here - line 35"""
user_data = {
'id': user_id,
'name': f'User_{user_id}',
'email': f'user{user_id}@example.com',
'active': user_id % 2 == 0
}
return user_data
def calculate_total(items: list) -> float:
"""Set breakpoint here - line 45"""
total = 0.0
for item in items:
price = item.get('price', 0)
quantity = item.get('quantity', 1)
total += price * quantity
return total
def fetch_data(query: str) -> list:
"""Set breakpoint here - line 55"""
results = []
for i in range(random.randint(1, 5)):
results.append({'id': i, 'query': query, 'value': random.random() * 100})
return results
iteration = 0
while True:
iteration += 1
print(f"\n[Iteration {iteration}]")
user = process_user(random.randint(1, 100))
print(f" User: {user['name']}")
items = [{'price': random.uniform(10, 50), 'quantity': random.randint(1, 5)}]
total = calculate_total(items)
print(f" Total: ${total:.2f}")
data = fetch_data(random.choice(['products', 'orders']))
print(f" Data: {len(data)} results")
time.sleep(3)