import requests import time BASE_URL = "http://localhost:8000/api/v1" def test_vapid_key(): print("Testing VAPID Key Endpoint...") try: res = requests.get(f"{BASE_URL}/reminders/vapid-key") if res.status_code == 200: key = res.json().get("public_key") print(f"✅ Public Key: {key[:10]}...") return key else: print(f"❌ Failed to get key: {res.text}") except Exception as e: print(f"❌ Connection Error: {e}") def test_subscribe(): print("\nTesting Push Subscription...") mock_sub = { "endpoint": "https://fcm.googleapis.com/fcm/send/test_subscription", "keys": { "p256dh": "test_p256dh_key", "auth": "test_auth_key" } } try: res = requests.post(f"{BASE_URL}/reminders/subscribe", json=mock_sub) print(f"Subscription Response: {res.json()}") except Exception as e: print(f"Subscription Error: {e}") def test_add_reminder_with_image(): print("\nTesting Reminder with Image...") # Mock file files = {'image': ('test_pill.jpg', b'fake_image_content', 'image/jpeg')} data = {'text': "Take blue pill", 'due_time': "10:00 AM"} try: res = requests.post(f"{BASE_URL}/reminders/add", data=data, files=files) print(f"Add Reminder Response: {res.json()}") except Exception as e: print(f"Add Reminder Error: {e}") if __name__ == "__main__": print("Note: Ensure server is running (uvicorn app.main:app --reload)") test_vapid_key() test_subscribe() test_add_reminder_with_image()