I have a test case where I am testing a POST service using pytest hosted with FastAPI Uvicorn. However the response is getting responded with status code 307. But this doesn't happen on actual webservice is tested through a browser or curl. What is happening here?
from fastapi.testclient import TestClient
from src.main import app
import json
client = TestClient(app)
def test_get_confidence_ws():
data = {
"acc_id": 1234567801,
"remoteIp": "127.255.255.255",
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
}
response = client.post("/confidence", json=json.dumps(data))
assert response.status_code == 200
Test response
> assert response.status_code == 200
E assert 307 == 200
E + where 307 = <Response [307]>.status_code
EDIT:
Actual endpoint that is tested:
@app.post("/confidence/")
def get_confidence(json: LoginClassifierSchema):
...
response = {
"key" : "value"
}
return response
/confidence/and not/confidence? Since you didn't include the FastAPI code, it's hard to say - but that's usually the reason./in the end, the response code changes to422LoginClassifierSchemamodel.