-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_test.py
More file actions
132 lines (107 loc) · 3.97 KB
/
quick_test.py
File metadata and controls
132 lines (107 loc) · 3.97 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
"""
Quick test script for JARVIS features.
"""
import os
import sys
def test_contacts():
print("\n=== Testing Contacts ===")
try:
from core.contacts import add_contact, list_contacts, find_contact
# Add contacts
print(add_contact("John Doe", "555-1234", "john@example.com", "555-1234"))
print(add_contact("Jane Smith", "555-5678", "jane@example.com", "555-5678"))
# List contacts
print("All contacts:")
print(list_contacts())
# Find contact
print("Finding John:")
print(find_contact("John"))
return True
except Exception as e:
print(f"Error testing contacts: {e}")
return False
def test_calendar():
print("\n=== Testing Calendar ===")
try:
from core.calendar import add_event, get_upcoming_events, get_events_for_date
# Add events
print(add_event("Team Meeting", "tomorrow", "14:00", "Weekly team sync", "Conference Room A"))
print(add_event("Doctor Appointment", "next Monday", "10:30", "Annual checkup", "Medical Center"))
# Get upcoming events
print("Upcoming events:")
print(get_upcoming_events())
# Get events for tomorrow
print("Tomorrow's events:")
print(get_events_for_date("tomorrow"))
return True
except Exception as e:
print(f"Error testing calendar: {e}")
return False
def test_commands():
print("\n=== Testing Commands ===")
try:
from core.commands import run_command
# Test various commands
commands = [
"what can you do",
"open chrome",
"search for Python tutorials",
"what's the weather like today",
"add contact named Test User with phone 555-9999 email test@example.com",
"add event called Test Event on tomorrow at 15:00",
"show my upcoming events"
]
for cmd in commands:
print(f"\nCommand: {cmd}")
response = run_command(cmd)
print(f"Response: {response}")
return True
except Exception as e:
print(f"Error testing commands: {e}")
return False
def test_self_training():
print("\n=== Testing Self-Training ===")
try:
from core.self_training import record_interaction, get_training_stats
# Record some interactions
record_interaction("Hello JARVIS", "Hello! How can I help you today?", True)
record_interaction("What's the weather like?", "I don't have access to weather data right now.", False)
record_interaction("Open Chrome", "Opening Chrome.", True)
# Get training stats
stats = get_training_stats()
print("Training stats:")
for key, value in stats.items():
print(f"- {key}: {value}")
return True
except Exception as e:
print(f"Error testing self-training: {e}")
return False
def main():
print("JARVIS Quick Test")
print("================")
# Create data directory if it doesn't exist
data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
if not os.path.exists(data_dir):
try:
os.mkdir(data_dir)
print(f"Created data directory: {data_dir}")
except Exception as e:
print(f"Error creating data directory: {e}")
# Run tests
tests = [
("Contacts", test_contacts),
("Calendar", test_calendar),
("Commands", test_commands),
("Self-Training", test_self_training)
]
results = {}
for name, test_func in tests:
print(f"\nRunning {name} test...")
results[name] = test_func()
# Print summary
print("\n=== Test Summary ===")
for name, result in results.items():
status = "PASSED" if result else "FAILED"
print(f"{name}: {status}")
if __name__ == "__main__":
main()