-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Problem
The endpoint POST /api/manufacturer works flawlessly in swagger. When calling the identical endpoint using a simple httpx pytest, the whole test fails with a 500 status code. I couldnt locate the error so I had to write a dirty workaround. Technically the API should work and the manufacturer is added. Hence I decided to call GET /api/manufacturers and check the list of all manufacturers.
Despite the 500 status code, the manufacturer was added to the database.
Code in question
@pytest.mark.asyncio
async def test_pass_create_manufacturers(api_client):
"""See issue no. XXXX
"""
payload = {
"name": uuid.uuid4().hex[:7],
"website": f"https://{uuid.uuid7().hex[:7]}.de"
}
_ = await api_client.post("/api/manufacturers", json=payload)
list_of_manufacturers = await api_client.get("/api/manufacturers")
manufacturers = list_of_manufacturers.json().get("manufacturers")
for manufacturer in manufacturers:
if manufacturer.get("name") == payload["name"] and manufacturer.get("website") == payload["website"]:
pytest.skip("pass") # Enforces pytest to pass
raise RuntimeError("Somehow the Manufacturer was not created.")Expected behaviour
Endpoint should return 200 OK when adding a new manufacturer to hyperion. In Swagger it works (surprisingly).