-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
62 lines (56 loc) · 1.75 KB
/
test.py
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
from pathlib import Path
import pytest
from agents.react_graph import Splatter
def test_basic_operations():
splatter = Splatter()
# Test cases with initial states
test_cases = [
# Test file loading
{
"messages": [{
"role": "user",
"content": "Load and analyze the contents of test_file.py"
}],
"current_action_list": [],
"should_end": False,
"action_input": {
"file_path": Path("test_file.py")
}
},
# Test code analysis
{
"messages": [{
"role": "user",
"content": "Analyze this code: def hello(): print('world')"
}],
"current_action_list": [],
"should_end": False,
"action_input": {
"code": "def hello(): print('world')",
"analysis_type": "general"
}
},
# Test code explanation
{
"messages": [{
"role": "user",
"content": "Explain this code in detail: for i in range(10): print(i)"
}],
"current_action_list": [],
"should_end": False,
"action_input": {
"code": "for i in range(10): print(i)",
"detail_level": "high"
}
}
]
# Run each test case
for test_case in test_cases:
result = splatter.graph.invoke(test_case)
print("\nTest Case Result:")
print("Messages:", result["messages"])
print("Action Output:", result.get("action_output"))
print("Observation:", result.get("observation"))
print("-" * 50)
if __name__ == "__main__":
test_basic_operations()