Spaces:
Build error
Build error
| #!/usr/bin/env python3 | |
| """ | |
| Test script to verify Google Meet conference creation is working. | |
| Usage: | |
| python3 test_google_meet.py | |
| """ | |
| import sys | |
| import os | |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
| from datetime import datetime, timedelta | |
| from app.calendar.service import CalendarService | |
| from app.calendar.auth import CalendarAuth | |
| import json | |
| def test_google_meet_creation(): | |
| """Test creating an event with Google Meet.""" | |
| print("=" * 70) | |
| print("GOOGLE MEET CREATION TEST") | |
| print("=" * 70) | |
| try: | |
| # Initialize auth and service | |
| print("\n1. Initializing CalendarAuth...") | |
| auth = CalendarAuth() | |
| print("2. Getting credentials...") | |
| credentials = auth.load_credentials() | |
| if not credentials: | |
| print("β No credentials found!") | |
| print(" Run: python3 refresh_credentials.py") | |
| return False | |
| print(f"β Credentials loaded") | |
| print(f" Expired: {credentials.expired}") | |
| print(f" Expiry: {credentials.expiry}") | |
| # Initialize calendar service | |
| print("\n3. Initializing CalendarService...") | |
| service = CalendarService() | |
| # Create test event with Google Meet | |
| print("\n4. Creating test event with Google Meet...") | |
| # Schedule for 5 minutes from now | |
| start_time = datetime.now() + timedelta(minutes=5) | |
| end_time = start_time + timedelta(minutes=30) | |
| print(f" Title: TEST - Google Meet Verification") | |
| print(f" Start: {start_time}") | |
| print(f" End: {end_time}") | |
| print(f" Google Meet: ENABLED") | |
| event = service.create_event( | |
| summary="TEST - Google Meet Verification", | |
| start_time=start_time, | |
| end_time=end_time, | |
| description="Automated test to verify Google Meet creation is working", | |
| create_meet_conference=True | |
| ) | |
| print("\n5. Event created successfully!") | |
| print(f" Event ID: {event.get('id')}") | |
| # Check for Google Meet link | |
| print("\n6. Checking for Google Meet conference data...") | |
| meet_link = None | |
| # Method 1: Check conferenceData | |
| if 'conferenceData' in event: | |
| print(" β conferenceData found in event") | |
| conference_data = event['conferenceData'] | |
| print(f" Conference data keys: {list(conference_data.keys())}") | |
| if 'entryPoints' in conference_data: | |
| print(f" β entryPoints found") | |
| entry_points = conference_data['entryPoints'] | |
| print(f" Number of entry points: {len(entry_points)}") | |
| for idx, entry in enumerate(entry_points): | |
| print(f" Entry {idx+1}: {entry.get('entryPointType')} - {entry.get('uri', 'No URI')}") | |
| if entry.get('entryPointType') == 'video': | |
| meet_link = entry.get('uri') | |
| print(f" β VIDEO ENTRY FOUND: {meet_link}") | |
| else: | |
| print(" β οΈ No entryPoints in conferenceData") | |
| print(f" Available keys: {list(conference_data.keys())}") | |
| else: | |
| print(" β οΈ No conferenceData in event") | |
| # Method 2: Check hangoutLink (legacy) | |
| if not meet_link and 'hangoutLink' in event: | |
| meet_link = event['hangoutLink'] | |
| print(f" β hangoutLink found (legacy): {meet_link}") | |
| # Method 3: Check htmlLink | |
| if 'htmlLink' in event: | |
| print(f" π Calendar event link: {event['htmlLink']}") | |
| print("\n" + "=" * 70) | |
| print("TEST RESULTS") | |
| print("=" * 70) | |
| if meet_link: | |
| print(f"β SUCCESS! Google Meet link created:") | |
| print(f" {meet_link}") | |
| print(f"\nβ Event ID: {event.get('id')}") | |
| print(f"β Event link: {event.get('htmlLink')}") | |
| # Now delete the test event | |
| print("\n7. Cleaning up - deleting test event...") | |
| try: | |
| service._get_service().events().delete( | |
| calendarId='primary', | |
| eventId=event['id'] | |
| ).execute() | |
| print(" β Test event deleted") | |
| except Exception as e: | |
| print(f" β οΈ Could not delete test event: {e}") | |
| print(f" Please manually delete event ID: {event['id']}") | |
| return True | |
| else: | |
| print("β FAILED! No Google Meet link was created") | |
| print("\nπ DIAGNOSIS:") | |
| print(" The event was created but without a Google Meet conference.") | |
| print("\nπ‘ POSSIBLE CAUSES:") | |
| print(" 1. Google Calendar API might not have Meet enabled") | |
| print(" 2. OAuth scope might be missing conferenceData permissions") | |
| print(" 3. Account might not have Google Meet enabled") | |
| print("\nπ οΈ SOLUTION:") | |
| print(" Check Google Cloud Console -> APIs & Services -> Credentials") | |
| print(" Ensure these scopes are included:") | |
| print(" - https://www.googleapis.com/auth/calendar") | |
| print(" - https://www.googleapis.com/auth/calendar.events") | |
| # Clean up | |
| print("\n7. Cleaning up - deleting test event...") | |
| try: | |
| service._get_service().events().delete( | |
| calendarId='primary', | |
| eventId=event['id'] | |
| ).execute() | |
| print(" β Test event deleted") | |
| except Exception as e: | |
| print(f" β οΈ Could not delete: {e}") | |
| return False | |
| except Exception as e: | |
| print(f"\nβ TEST FAILED WITH ERROR:") | |
| print(f" {e}") | |
| import traceback | |
| traceback.print_exc() | |
| return False | |
| if __name__ == "__main__": | |
| print("\nVoiceCal.ai - Google Meet Integration Test") | |
| print("This will create and delete a test event") | |
| print() | |
| success = test_google_meet_creation() | |
| print("\n" + "=" * 70) | |
| if success: | |
| print("π Google Meet integration is working correctly!") | |
| else: | |
| print("β οΈ Google Meet integration needs attention") | |
| print("=" * 70) | |