-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_system.py
More file actions
181 lines (129 loc) · 4.46 KB
/
test_system.py
File metadata and controls
181 lines (129 loc) · 4.46 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
"""
Test Cases for AI Employee System
Demonstrates the full workflow from Inbox to Needs_Action.
"""
import os
import sys
import time
from pathlib import Path
# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent))
from agents.skills.file_skills import FileSkills, TextSkills, ActionLogger
from agents.core.claude_agent import ClaudeAgent
def test_file_skills():
"""Test basic file operations."""
print("\n=== Testing File Skills ===")
skills = FileSkills()
test_dir = Path("test_output")
test_dir.mkdir(exist_ok=True)
# Test write
test_file = test_dir / "test.md"
content = "# Test File\n\nThis is a test."
success = skills.write_file(str(test_file), content)
print(f"✓ Write file: {success}")
# Test read
read_content = skills.read_file(str(test_file))
print(f"✓ Read file: {len(read_content)} chars")
# Test move
moved_file = test_dir / "moved.md"
success = skills.move_file(str(test_file), str(moved_file))
print(f"✓ Move file: {success}")
# Cleanup
moved_file.unlink()
test_dir.rmdir()
print("✓ Cleanup complete")
def test_text_skills():
"""Test text processing."""
print("\n=== Testing Text Skills ===")
skills = TextSkills()
text = """# Important Meeting Notes
This is a very important meeting about the Q2 roadmap.
We need to discuss priorities and timelines.
#urgent #meeting #q2"""
# Test summarize
summary = skills.summarize_text(text, max_length=100)
print(f"✓ Summary: {summary}")
# Test metadata extraction
metadata = skills.extract_metadata(text)
print(f"✓ Metadata: {metadata}")
def test_action_logger():
"""Test action logging."""
print("\n=== Testing Action Logger ===")
logger = ActionLogger("test_output/test_log.json")
success = logger.log_action('test_action', {
'file': 'test.md',
'status': 'success'
})
print(f"✓ Log action: {success}")
# Cleanup
Path("test_output/test_log.json").unlink()
Path("test_output").rmdir()
def test_claude_agent():
"""Test Claude integration (requires API key)."""
print("\n=== Testing Claude Agent ===")
agent = ClaudeAgent()
if not agent.client:
print("⚠ Claude API key not configured - skipping")
return
# Test analysis
content = """# Urgent: Client Meeting Tomorrow
We have an important client meeting scheduled for tomorrow at 2 PM.
Please prepare the Q2 presentation and review the contract terms.
Action items:
- Finalize slides
- Print handouts
- Book conference room"""
analysis = agent.analyze_file(content, "client_meeting.md")
print(f"✓ Analysis: {analysis}")
def create_test_inbox_file():
"""Create a test file in the Inbox."""
print("\n=== Creating Test Inbox File ===")
vault_path = Path("vault")
inbox_path = vault_path / "Inbox"
inbox_path.mkdir(parents=True, exist_ok=True)
test_file = inbox_path / "test_task.md"
content = """# New Task: Update Documentation
**Priority:** High
**Due Date:** 2026-04-15
## Description
We need to update the API documentation to reflect the new endpoints added in v2.0.
## Tasks
- [ ] Document new authentication flow
- [ ] Add code examples
- [ ] Update changelog
## Notes
This is blocking the release, so please prioritize.
#documentation #api #urgent
"""
with open(test_file, 'w', encoding='utf-8') as f:
f.write(content)
print(f"✓ Created test file: {test_file}")
print(" The watcher should process this file automatically")
print(" Check vault/Needs_Action/ for the moved file and analysis")
def run_all_tests():
"""Run all test cases."""
print("=" * 60)
print("AI EMPLOYEE SYSTEM - TEST SUITE")
print("=" * 60)
try:
test_file_skills()
test_text_skills()
test_action_logger()
test_claude_agent()
print("\n" + "=" * 60)
print("INTEGRATION TEST")
print("=" * 60)
create_test_inbox_file()
print("\n" + "=" * 60)
print("✓ All tests completed successfully!")
print("=" * 60)
print("\nTo test the full system:")
print("1. Ensure the system is running: python main.py")
print("2. The test file should be automatically processed")
print("3. Check vault/Needs_Action/ for results")
except Exception as e:
print(f"\n✗ Test failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
run_all_tests()