I am currently working on automating tests in Python using pytest and the OpenAI API on VSCode on Windows. As a first step, I attempted a simple test to auto-login to my web application hosted on localhost. However, I encountered the following error:
assert 404 == 200
E + where 404 = <Response [404]>.status_code
Here is my code:
import os
import openai
import requests
import pytest
openai.api_key = os.getenv("OPENAI_API_KEY")
ENDPOINT = "http://localhost:9518/auth/sign-in/"
def test_can_sign_in():
payload = {
"email": "[email protected]",
"password": "password",
"remember_me": False
}
response = requests.post(ENDPOINT, json=payload)
assert response.status_code == 200`
Thank you for your help 🙂
I have already tried verifying and changing the ENDPOINT. The endpoint is functional (I can open it in my browser). I also verified the sign-in API method in the documentation.
I would like this test to allow automatic login to the website while it’s running.
Cristaline is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1