]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Fix inconsistent response code when item already exists in docs for testing (#11818)
authorLuke Okomilo <github@email.okomilo.com>
Thu, 15 Aug 2024 22:31:16 +0000 (23:31 +0100)
committerGitHub <noreply@github.com>
Thu, 15 Aug 2024 22:31:16 +0000 (22:31 +0000)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs_src/app_testing/app_b_an/main.py
docs_src/app_testing/app_b_an/test_main.py
docs_src/app_testing/app_b_an_py310/main.py
docs_src/app_testing/app_b_an_py310/test_main.py
docs_src/app_testing/app_b_an_py39/main.py
docs_src/app_testing/app_b_an_py39/test_main.py

index c63134fc9b0070752377f489c73002a7da17ab66..c66278fdd01fcf5ec209d8151192d013b0dd7157 100644 (file)
@@ -34,6 +34,6 @@ async def create_item(item: Item, x_token: Annotated[str, Header()]):
     if x_token != fake_secret_token:
         raise HTTPException(status_code=400, detail="Invalid X-Token header")
     if item.id in fake_db:
-        raise HTTPException(status_code=400, detail="Item already exists")
+        raise HTTPException(status_code=409, detail="Item already exists")
     fake_db[item.id] = item
     return item
index e2eda449d459a1f370bc1c00fa1782a58e3018b7..4e1c51ecc861d1d6a59c54fb9221272d8e13ee5f 100644 (file)
@@ -61,5 +61,5 @@ def test_create_existing_item():
             "description": "There goes my stealer",
         },
     )
-    assert response.status_code == 400
+    assert response.status_code == 409
     assert response.json() == {"detail": "Item already exists"}
index 48c27a0b8839b63eb316602c0d740f890de5cb25..c5952be0b3e1c7502469192aa9a0f351d1f5b104 100644 (file)
@@ -33,6 +33,6 @@ async def create_item(item: Item, x_token: Annotated[str, Header()]):
     if x_token != fake_secret_token:
         raise HTTPException(status_code=400, detail="Invalid X-Token header")
     if item.id in fake_db:
-        raise HTTPException(status_code=400, detail="Item already exists")
+        raise HTTPException(status_code=409, detail="Item already exists")
     fake_db[item.id] = item
     return item
index e2eda449d459a1f370bc1c00fa1782a58e3018b7..4e1c51ecc861d1d6a59c54fb9221272d8e13ee5f 100644 (file)
@@ -61,5 +61,5 @@ def test_create_existing_item():
             "description": "There goes my stealer",
         },
     )
-    assert response.status_code == 400
+    assert response.status_code == 409
     assert response.json() == {"detail": "Item already exists"}
index 935a510b743c3fc664a11a0114444cbeb3184a37..142e23a26ae89d1fbd653410b69ba28b0dcda042 100644 (file)
@@ -33,6 +33,6 @@ async def create_item(item: Item, x_token: Annotated[str, Header()]):
     if x_token != fake_secret_token:
         raise HTTPException(status_code=400, detail="Invalid X-Token header")
     if item.id in fake_db:
-        raise HTTPException(status_code=400, detail="Item already exists")
+        raise HTTPException(status_code=409, detail="Item already exists")
     fake_db[item.id] = item
     return item
index e2eda449d459a1f370bc1c00fa1782a58e3018b7..4e1c51ecc861d1d6a59c54fb9221272d8e13ee5f 100644 (file)
@@ -61,5 +61,5 @@ def test_create_existing_item():
             "description": "There goes my stealer",
         },
     )
-    assert response.status_code == 400
+    assert response.status_code == 409
     assert response.json() == {"detail": "Item already exists"}