Files
yellow-bank-soal/test_api.py
2026-06-20 01:43:39 +07:00

20 lines
671 B
Python

import asyncio
import httpx
import json
async def run():
async with httpx.AsyncClient() as client:
# 1. Login
resp = await client.post("http://localhost:8000/api/v1/auth/admin-login", json={"username": "admin", "password": "admin123"})
print("Login resp:", resp.json())
token = resp.json().get("access_token")
# 2. Fetch questions
resp2 = await client.get(
"http://localhost:8000/api/v1/admin/tryouts/132380/questions",
headers={"Authorization": f"Bearer {token}", "X-Website-ID": "1"}
)
print("Questions resp:", json.dumps(resp2.json(), indent=2))
asyncio.run(run())