Browse Source

📝 Replace HTTP code returned in case of existing user error in docs for testing (#4482)

Co-authored-by: Sebastián Ramírez <[email protected]>
pull/10915/head
Tristan Marion 1 year ago
committed by GitHub
parent
commit
a1ea708044
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      docs_src/app_testing/app_b/main.py
  2. 2
      docs_src/app_testing/app_b/test_main.py
  3. 2
      docs_src/app_testing/app_b_py310/main.py
  4. 2
      docs_src/app_testing/app_b_py310/test_main.py

2
docs_src/app_testing/app_b/main.py

@ -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

2
docs_src/app_testing/app_b/test_main.py

@ -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"}

2
docs_src/app_testing/app_b_py310/main.py

@ -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

2
docs_src/app_testing/app_b_py310/test_main.py

@ -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"}

Loading…
Cancel
Save