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
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.pythonLocation }}
|
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
|
- name: Install Dependencies
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: pip install -r requirements-tests.txt
|
run: pip install -r requirements-tests.txt
|
||||||
|
|
@ -62,7 +62,7 @@ jobs:
|
||||||
id: cache
|
id: cache
|
||||||
with:
|
with:
|
||||||
path: ${{ env.pythonLocation }}
|
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
|
- name: Install Dependencies
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
run: pip install -r requirements-tests.txt
|
run: pip install -r requirements-tests.txt
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ def test_jsonable_encoder_requiring_error():
|
||||||
"loc": ["body", 0, "age"],
|
"loc": ["body", 0, "age"],
|
||||||
"msg": "Input should be greater than 0",
|
"msg": "Input should be greater than 0",
|
||||||
"input": -1.0,
|
"input": -1.0,
|
||||||
"ctx": {"gt": "0"},
|
"ctx": {"gt": 0},
|
||||||
"url": match_pydantic_error_url("greater_than"),
|
"url": match_pydantic_error_url("greater_than"),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -84,25 +84,12 @@ def test_put_incorrect_body_multiple():
|
||||||
"input": {"age": "five"},
|
"input": {"age": "five"},
|
||||||
"url": match_pydantic_error_url("missing"),
|
"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",
|
"type": "decimal_parsing",
|
||||||
"loc": [
|
"loc": ["body", 0, "age"],
|
||||||
"body",
|
|
||||||
0,
|
|
||||||
"age",
|
|
||||||
"function-after[to_decimal(), "
|
|
||||||
"union[int,constrained-str,function-plain[str()]]]",
|
|
||||||
],
|
|
||||||
"msg": "Input should be a valid decimal",
|
"msg": "Input should be a valid decimal",
|
||||||
"input": "five",
|
"input": "five",
|
||||||
|
"url": match_pydantic_error_url("decimal_parsing"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "missing",
|
"type": "missing",
|
||||||
|
|
@ -111,25 +98,12 @@ def test_put_incorrect_body_multiple():
|
||||||
"input": {"age": "six"},
|
"input": {"age": "six"},
|
||||||
"url": match_pydantic_error_url("missing"),
|
"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",
|
"type": "decimal_parsing",
|
||||||
"loc": [
|
"loc": ["body", 1, "age"],
|
||||||
"body",
|
|
||||||
1,
|
|
||||||
"age",
|
|
||||||
"function-after[to_decimal(), "
|
|
||||||
"union[int,constrained-str,function-plain[str()]]]",
|
|
||||||
],
|
|
||||||
"msg": "Input should be a valid decimal",
|
"msg": "Input should be a valid decimal",
|
||||||
"input": "six",
|
"input": "six",
|
||||||
|
"url": match_pydantic_error_url("decimal_parsing"),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -87,7 +87,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -116,7 +116,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -126,7 +126,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -151,7 +151,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -90,7 +90,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -119,7 +119,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -129,7 +129,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -154,7 +154,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -90,7 +90,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -119,7 +119,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -129,7 +129,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -154,7 +154,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,9 @@ def test_openapi_schema():
|
||||||
"schema": {
|
"schema": {
|
||||||
"title": "Items",
|
"title": "Items",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {"$ref": "#/components/schemas/ItemInput"},
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Item-Input"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -141,7 +143,7 @@ def test_openapi_schema():
|
||||||
"items": {
|
"items": {
|
||||||
"title": "Items",
|
"title": "Items",
|
||||||
"type": "array",
|
"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",
|
"title": "Item",
|
||||||
"required": ["name"],
|
"required": ["name"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -168,7 +170,7 @@ def test_openapi_schema():
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "description"],
|
"required": ["name", "description"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ def test_openapi_schema():
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -57,7 +57,7 @@ def test_openapi_schema():
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -67,7 +67,7 @@ def test_openapi_schema():
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "price"],
|
"required": ["name", "price"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -91,7 +91,7 @@ def test_openapi_schema():
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ def test_openapi_schema():
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -57,7 +57,7 @@ def test_openapi_schema():
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -67,7 +67,7 @@ def test_openapi_schema():
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "price"],
|
"required": ["name", "price"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -91,7 +91,7 @@ def test_openapi_schema():
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -64,7 +64,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -74,7 +74,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "price"],
|
"required": ["name", "price"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -98,7 +98,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/ItemOutput"
|
"$ref": "#/components/schemas/Item-Output"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -64,7 +64,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {"$ref": "#/components/schemas/ItemInput"}
|
"schema": {"$ref": "#/components/schemas/Item-Input"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": True,
|
"required": True,
|
||||||
|
|
@ -74,7 +74,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"ItemInput": {
|
"Item-Input": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "price"],
|
"required": ["name", "price"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
@ -98,7 +98,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"ItemOutput": {
|
"Item-Output": {
|
||||||
"title": "Item",
|
"title": "Item",
|
||||||
"required": ["name", "description", "price", "tax", "tags"],
|
"required": ["name", "description", "price", "tax", "tags"],
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue