Spaces:
Sleeping

studiq-backend / test_otp_api_complete.py
StudIQ Deploy Bot
Deploy from GitHub 8f93d465b8f4886bb4530ba6a37ea856fea77c8f
462326d
Raw History Blame Contribute Delete
1.07 kB
import httpx
import asyncio
async def test_email_otp():
send_url = "http://localhost:8000/api/v1/auth/otp/email/send"
verify_url = "http://localhost:8000/api/v1/auth/otp/email/verify"
email = "test_user_antigravity@studiq.app"
print(f"Sending request to send OTP to {email}...")
async with httpx.AsyncClient() as client:
try:
resp = await client.post(send_url, json={"email": email}, timeout=20.0)
print(f"Send OTP Status Code: {resp.status_code}")
print(f"Send OTP Response: {resp.text}")
if resp.status_code == 200:
print("\nVerifying OTP with code '123456'...")
resp_verify = await client.post(verify_url, json={"email": email, "otp": "123456"}, timeout=20.0)
print(f"Verify OTP Status Code: {resp_verify.status_code}")
print(f"Verify OTP Response: {resp_verify.text}")
except Exception as e:
print(f"Request failed: {e}")
if __name__ == "__main__":
asyncio.run(test_email_otp())