-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api_client.py
More file actions
49 lines (40 loc) · 1.57 KB
/
Copy pathtest_api_client.py
File metadata and controls
49 lines (40 loc) · 1.57 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
#!/usr/bin/env python3
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
from eventcalendar.core.api_client import CalendarAPIClient
def main():
"""Simple test function to verify that the API client works correctly."""
print("Testing CalendarAPIClient...")
# Check for API key
api_key = os.environ.get('GEMINI_API_KEY_FREE') or os.environ.get('GEMINI_API_KEY')
if not api_key:
print("Error: GEMINI_API_KEY_FREE or GEMINI_API_KEY environment variable not set.")
print("Please set one of them before running this test.")
sys.exit(1)
# Initialize the client
try:
client = CalendarAPIClient(api_key=api_key)
print("Successfully initialized the API client.")
except Exception as e:
print(f"Error initializing the API client: {e}")
sys.exit(1)
# Test a simple event creation
event_description = "Coffee with John tomorrow at 10am"
print(f"Testing event creation with description: '{event_description}'")
try:
result = client.create_calendar_event(
event_description=event_description,
image_data=[],
status_callback=lambda msg: print(f"Status: {msg}")
)
print("\nAPI Response:")
print("-" * 50)
print(result[:500] + "..." if len(result) > 500 else result)
print("-" * 50)
print("Test completed successfully!")
except Exception as e:
print(f"Error creating calendar event: {e}")
sys.exit(1)
if __name__ == "__main__":
main()