]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Replace HTTP code returned in case of existing user error in docs for testing ...
authorTristan Marion <trismarion@gmail.com>
Tue, 9 Jan 2024 14:44:08 +0000 (15:44 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Jan 2024 14:44:08 +0000 (18:44 +0400)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs_src/app_testing/app_b/main.py
docs_src/app_testing/app_b/test_main.py
docs_src/app_testing/app_b_py310/main.py
docs_src/app_testing/app_b_py310/test_main.py

index 11558b8e813f4e0afecc9bea846b8149ed10e674..45a103378388a042aef5c23281263285ec5e9fd0 100644 (file)
@@ -33,6 +33,6 @@ async def create_item(item: Item, x_token: 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 d186b8ecbacfa431a40af18918037ead306a2c8e..4e2b98e237c3abf06e62b41cc3b781aa4acba7ba 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 b4c72de5c94313487f4070bfb9e1a4ace9b2d935..eccedcc7ce2ecb208a75bd0a8b5c1f02040622ba 100644 (file)
@@ -31,6 +31,6 @@ async def create_item(item: Item, x_token: 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 d186b8ecbacfa431a40af18918037ead306a2c8e..4e2b98e237c3abf06e62b41cc3b781aa4acba7ba 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"}