|
|
|
|
|
|
|
|
|
|
|
Write-Host "Testing IITM LLM Quiz Solver API" -ForegroundColor Cyan
|
|
|
Write-Host "=================================" -ForegroundColor Cyan
|
|
|
Write-Host ""
|
|
|
|
|
|
|
|
|
Write-Host "1. Testing /health endpoint..." -ForegroundColor Yellow
|
|
|
try {
|
|
|
$health = Invoke-RestMethod -Uri "http://127.0.0.1:8000/health" -Method GET -ErrorAction Stop
|
|
|
Write-Host " β Server is running!" -ForegroundColor Green
|
|
|
Write-Host " Response: $($health | ConvertTo-Json)" -ForegroundColor Gray
|
|
|
} catch {
|
|
|
Write-Host " β Server is NOT running or not accessible" -ForegroundColor Red
|
|
|
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Red
|
|
|
Write-Host ""
|
|
|
Write-Host " Please start the server first:" -ForegroundColor Yellow
|
|
|
Write-Host " python -m app.main" -ForegroundColor Cyan
|
|
|
exit 1
|
|
|
}
|
|
|
|
|
|
Write-Host ""
|
|
|
|
|
|
|
|
|
Write-Host "2. Testing / endpoint..." -ForegroundColor Yellow
|
|
|
try {
|
|
|
$root = Invoke-RestMethod -Uri "http://127.0.0.1:8000/" -Method GET -ErrorAction Stop
|
|
|
Write-Host " β Root endpoint works!" -ForegroundColor Green
|
|
|
Write-Host " Available endpoints:" -ForegroundColor Gray
|
|
|
$root.endpoints.PSObject.Properties | ForEach-Object {
|
|
|
Write-Host " $($_.Name): $($_.Value)" -ForegroundColor Gray
|
|
|
}
|
|
|
} catch {
|
|
|
Write-Host " β Root endpoint failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
|
}
|
|
|
|
|
|
Write-Host ""
|
|
|
|
|
|
|
|
|
Write-Host "3. Testing /env-check endpoint..." -ForegroundColor Yellow
|
|
|
try {
|
|
|
$envCheck = Invoke-RestMethod -Uri "http://127.0.0.1:8000/env-check" -Method GET -ErrorAction Stop
|
|
|
Write-Host " β Environment check works!" -ForegroundColor Green
|
|
|
Write-Host " QUIZ_SECRET: $($envCheck.variables.QUIZ_SECRET.set)" -ForegroundColor Gray
|
|
|
Write-Host " OPENAI_API_KEY: $($envCheck.variables.OPENAI_API_KEY.set)" -ForegroundColor Gray
|
|
|
Write-Host " Ready: $($envCheck.ready)" -ForegroundColor Gray
|
|
|
} catch {
|
|
|
Write-Host " β Env check failed: $($_.Exception.Message)" -ForegroundColor Red
|
|
|
}
|
|
|
|
|
|
Write-Host ""
|
|
|
|
|
|
|
|
|
Write-Host "4. Testing /demo endpoint..." -ForegroundColor Yellow
|
|
|
Write-Host " (This will make an actual request)" -ForegroundColor Gray
|
|
|
|
|
|
|
|
|
if (-not $env:QUIZ_SECRET) {
|
|
|
$env:QUIZ_SECRET = "EasyQuiz"
|
|
|
}
|
|
|
|
|
|
$body = @{
|
|
|
email = "24f2005753@ds.study.iitm.ac.in"
|
|
|
secret = "EasyQuiz"
|
|
|
url = "https://tds-llm-analysis.s-anand.net/demo"
|
|
|
} | ConvertTo-Json
|
|
|
|
|
|
try {
|
|
|
Write-Host " Sending request..." -ForegroundColor Gray
|
|
|
$response = Invoke-RestMethod `
|
|
|
-Uri "http://127.0.0.1:8000/demo" `
|
|
|
-Method POST `
|
|
|
-ContentType "application/json" `
|
|
|
-Body $body `
|
|
|
-ErrorAction Stop
|
|
|
|
|
|
Write-Host " β Demo endpoint works!" -ForegroundColor Green
|
|
|
Write-Host " Response:" -ForegroundColor Gray
|
|
|
$response | ConvertTo-Json -Depth 10 | Write-Host
|
|
|
} catch {
|
|
|
Write-Host " β Demo endpoint failed" -ForegroundColor Red
|
|
|
Write-Host " Status: $($_.Exception.Response.StatusCode.value__)" -ForegroundColor Yellow
|
|
|
if ($_.ErrorDetails.Message) {
|
|
|
Write-Host " Error: $($_.ErrorDetails.Message)" -ForegroundColor Yellow
|
|
|
} else {
|
|
|
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Yellow
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Write-Host ""
|
|
|
Write-Host "=================================" -ForegroundColor Cyan
|
|
|
Write-Host "Test complete!" -ForegroundColor Cyan
|
|
|
|
|
|
|