mirror of https://github.com/tiangolo/fastapi.git
♻️ Refactor tests for new Pydantic 2.2.1 (#10115)
This commit is contained in:
parent
b406dd9174
commit
7a06de2bb9
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
id: cache
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v04
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v05
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: pip install -r requirements-tests.txt
|
||||
|
|
@ -62,7 +62,7 @@ jobs:
|
|||
id: cache
|
||||
with:
|
||||
path: ${{ env.pythonLocation }}
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v04
|
||||
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v05
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: pip install -r requirements-tests.txt
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ def test_jsonable_encoder_requiring_error():
|
|||
"loc": ["body", 0, "age"],
|
||||
"msg": "Input should be greater than 0",
|
||||
"input": -1.0,
|
||||
"ctx": {"gt": "0"},
|
||||
"ctx": {"gt": 0},
|
||||
"url": match_pydantic_error_url("greater_than"),
|
||||
}
|
||||
]
|
||||
|
|
@ -84,25 +84,12 @@ def test_put_incorrect_body_multiple():
|
|||
"input": {"age": "five"},
|
||||
"url": match_pydantic_error_url("missing"),
|
||||
},
|
||||
{
|
||||
"ctx": {"class": "Decimal"},
|
||||
"input": "five",
|
||||
"loc": ["body", 0, "age", "is-instance[Decimal]"],
|
||||
"msg": "Input should be an instance of Decimal",
|
||||
"type": "is_instance_of",
|
||||
"url": match_pydantic_error_url("is_instance_of"),
|
||||
},
|
||||
{
|
||||
"type": "decimal_parsing",
|
||||
"loc": [
|
||||
"body",
|
||||
0,
|
||||
"age",
|
||||
"function-after[to_decimal(), "
|
||||
"union[int,constrained-str,function-plain[str()]]]",
|
||||
],
|
||||
"loc": ["body", 0, "age"],
|
||||
"msg": "Input should be a valid decimal",
|
||||
"input": "five",
|
||||
"url": match_pydantic_error_url("decimal_parsing"),
|
||||
},
|
||||
{
|
||||
"type": "missing",
|
||||
|
|
@ -111,25 +98,12 @@ def test_put_incorrect_body_multiple():
|
|||
"input": {"age": "six"},
|
||||
"url": match_pydantic_error_url("missing"),
|
||||
},
|
||||
{
|
||||
"ctx": {"class": "Decimal"},
|
||||
"input": "six",
|
||||
"loc": ["body", 1, "age", "is-instance[Decimal]"],
|
||||
"msg": "Input should be an instance of Decimal",
|
||||
"type": "is_instance_of",
|
||||
"url": match_pydantic_error_url("is_instance_of"),
|
||||
},
|
||||
{
|
||||
"type": "decimal_parsing",
|
||||
"loc": [
|
||||
"body",
|
||||
1,
|
||||
"age",
|
||||
"function-after[to_decimal(), "
|
||||
"union[int,constrained-str,function-plain[str()]]]",
|
||||
],
|
||||
"loc": ["body", 1, "age"],
|
||||
"msg": "Input should be a valid decimal",
|
||||
"input": "six",
|
||||
"url": match_pydantic_error_url("decimal_parsing"),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -87,7 +87,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -116,7 +116,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -126,7 +126,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -151,7 +151,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"type": "object",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -119,7 +119,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -129,7 +129,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -154,7 +154,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"type": "object",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -119,7 +119,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -129,7 +129,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -154,7 +154,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"type": "object",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
|
|
|
|||
|
|
@ -79,7 +79,9 @@ def test_openapi_schema():
|
|||
"schema": {
|
||||
"title": "Items",
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/components/schemas/ItemInput"},
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Item-Input"
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -141,7 +143,7 @@ def test_openapi_schema():
|
|||
"items": {
|
||||
"title": "Items",
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/components/schemas/ItemOutput"},
|
||||
"items": {"$ref": "#/components/schemas/Item-Output"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -156,7 +158,7 @@ def test_openapi_schema():
|
|||
}
|
||||
},
|
||||
},
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"required": ["name"],
|
||||
"type": "object",
|
||||
|
|
@ -168,7 +170,7 @@ def test_openapi_schema():
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"required": ["name", "description"],
|
||||
"type": "object",
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ def test_openapi_schema():
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -57,7 +57,7 @@ def test_openapi_schema():
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -67,7 +67,7 @@ def test_openapi_schema():
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"required": ["name", "price"],
|
||||
"type": "object",
|
||||
|
|
@ -91,7 +91,7 @@ def test_openapi_schema():
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
"type": "object",
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ def test_openapi_schema():
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -57,7 +57,7 @@ def test_openapi_schema():
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -67,7 +67,7 @@ def test_openapi_schema():
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"required": ["name", "price"],
|
||||
"type": "object",
|
||||
|
|
@ -91,7 +91,7 @@ def test_openapi_schema():
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
"type": "object",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -64,7 +64,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -74,7 +74,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"required": ["name", "price"],
|
||||
"type": "object",
|
||||
|
|
@ -98,7 +98,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
"type": "object",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ItemOutput"
|
||||
"$ref": "#/components/schemas/Item-Output"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -64,7 +64,7 @@ def test_openapi_schema(client: TestClient):
|
|||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
||||
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||
}
|
||||
},
|
||||
"required": True,
|
||||
|
|
@ -74,7 +74,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"ItemInput": {
|
||||
"Item-Input": {
|
||||
"title": "Item",
|
||||
"required": ["name", "price"],
|
||||
"type": "object",
|
||||
|
|
@ -98,7 +98,7 @@ def test_openapi_schema(client: TestClient):
|
|||
},
|
||||
},
|
||||
},
|
||||
"ItemOutput": {
|
||||
"Item-Output": {
|
||||
"title": "Item",
|
||||
"required": ["name", "description", "price", "tax", "tags"],
|
||||
"type": "object",
|
||||
|
|
|
|||
Loading…
Reference in New Issue