Browse Source
test: clean up JSON decode error tests per review feedback
pull/14089/head
Arif Dogan
8 months ago
No known key found for this signature in database
GPG Key ID: A2131177E83422CE
1 changed files with
1 additions and
15 deletions
-
tests/test_json_body_decode_error.py
|
|
@ -22,7 +22,7 @@ class Item(BaseModel): |
|
|
|
|
|
|
|
|
@app.post("/items/") |
|
|
@app.post("/items/") |
|
|
async def create_item(item: Item): |
|
|
async def create_item(item: Item): |
|
|
return item |
|
|
return item # pragma: no cover |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client = TestClient(app) |
|
|
client = TestClient(app) |
|
|
@ -155,17 +155,3 @@ def test_json_decode_error_snippet_ellipsis( |
|
|
snippet = error["ctx"]["snippet"] |
|
|
snippet = error["ctx"]["snippet"] |
|
|
assert snippet.startswith("...") == expected_starts_with_ellipsis |
|
|
assert snippet.startswith("...") == expected_starts_with_ellipsis |
|
|
assert snippet.endswith("...") == expected_ends_with_ellipsis |
|
|
assert snippet.endswith("...") == expected_ends_with_ellipsis |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_successful_item_creation(): |
|
|
|
|
|
response = client.post( |
|
|
|
|
|
"/items/", |
|
|
|
|
|
json={"name": "Test Item", "price": 19.99, |
|
|
|
|
|
"description": "A test item"}, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
assert response.status_code == 200 |
|
|
|
|
|
data = response.json() |
|
|
|
|
|
assert data["name"] == "Test Item" |
|
|
|
|
|
assert data["price"] == 19.99 |
|
|
|
|
|
assert data["description"] == "A test item" |
|
|
|
|
|
|