Browse Source

🎨 Format code

pull/14611/head
Sebastián Ramírez 7 months ago
parent
commit
07b9a62ff2
  1. 10
      tests/test_additional_responses_custom_model_in_callback.py
  2. 6
      tests/test_multi_body_errors.py
  3. 6
      tests/test_openapi_servers.py
  4. 14
      tests/test_regex_deprecated_body.py
  5. 6
      tests/test_tutorial/test_behind_a_proxy/test_tutorial003.py
  6. 6
      tests/test_tutorial/test_behind_a_proxy/test_tutorial004.py
  7. 6
      tests/test_tutorial/test_dataclasses/test_tutorial002.py
  8. 14
      tests/test_tutorial/test_extra_data_types/test_tutorial001.py
  9. 30
      tests/test_tutorial/test_extra_models/test_tutorial003.py
  10. 18
      tests/test_tutorial/test_request_files/test_tutorial001_02.py
  11. 14
      tests/test_tutorial/test_response_model/test_tutorial003.py
  12. 27
      tests/test_tutorial/test_response_model/test_tutorial003_01.py
  13. 10
      tests/test_tutorial/test_response_model/test_tutorial004.py
  14. 10
      tests/test_tutorial/test_response_model/test_tutorial005.py
  15. 10
      tests/test_tutorial/test_response_model/test_tutorial006.py
  16. 16
      tests/test_tutorial/test_security/test_tutorial005.py

10
tests/test_additional_responses_custom_model_in_callback.py

@ -32,7 +32,8 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -116,7 +117,9 @@ def test_openapi_schema():
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
@ -138,4 +141,5 @@ def test_openapi_schema():
},
}
},
})
}
)

6
tests/test_multi_body_errors.py

@ -25,14 +25,16 @@ client = TestClient(app)
def test_put_correct_body():
response = client.post("/items/", json=[{"name": "Foo", "age": 5}])
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"item": [
{
"name": "Foo",
"age": "5",
}
]
})
}
)
def test_jsonable_encoder_requiring_error():

6
tests/test_openapi_servers.py

@ -30,7 +30,8 @@ def test_app():
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"servers": [
@ -55,4 +56,5 @@ def test_openapi_schema():
}
}
},
})
}
)

14
tests/test_regex_deprecated_body.py

@ -65,7 +65,8 @@ def test_openapi_schema():
client = get_client()
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -76,7 +77,9 @@ def test_openapi_schema():
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {"$ref": "#/components/schemas/Body_read_items_items__post"}
"schema": {
"$ref": "#/components/schemas/Body_read_items_items__post"
}
}
}
},
@ -117,7 +120,9 @@ def test_openapi_schema():
"HTTPValidationError": {
"properties": {
"detail": {
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
"type": "array",
"title": "Detail",
}
@ -143,4 +148,5 @@ def test_openapi_schema():
},
}
},
})
}
)

6
tests/test_tutorial/test_behind_a_proxy/test_tutorial003.py

@ -15,7 +15,8 @@ def test_main():
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"servers": [
@ -43,4 +44,5 @@ def test_openapi_schema():
}
}
},
})
}
)

6
tests/test_tutorial/test_behind_a_proxy/test_tutorial004.py

@ -15,7 +15,8 @@ def test_main():
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"servers": [
@ -42,4 +43,5 @@ def test_openapi_schema():
}
}
},
})
}
)

6
tests/test_tutorial/test_dataclasses/test_tutorial002.py

@ -37,7 +37,8 @@ def test_get_item(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -84,4 +85,5 @@ def test_openapi_schema(client: TestClient):
}
}
},
})
}
)

14
tests/test_tutorial/test_extra_data_types/test_tutorial001.py

@ -47,7 +47,8 @@ def test_extra_types(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -87,7 +88,9 @@ def test_openapi_schema(client: TestClient):
"required": True,
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/Body_read_items_items__item_id__put"}
"schema": {
"$ref": "#/components/schemas/Body_read_items_items__item_id__put"
}
}
},
},
@ -148,10 +151,13 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
}
},
})
}
)

30
tests/test_tutorial/test_extra_models/test_tutorial003.py

@ -43,7 +43,8 @@ def test_get_plane(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -57,8 +58,12 @@ def test_openapi_schema(client: TestClient):
"schema": {
"title": "Response Read Item Items Item Id Get",
"anyOf": [
{"$ref": "#/components/schemas/PlaneItem"},
{"$ref": "#/components/schemas/CarItem"},
{
"$ref": "#/components/schemas/PlaneItem"
},
{
"$ref": "#/components/schemas/CarItem"
},
],
}
}
@ -96,7 +101,11 @@ def test_openapi_schema(client: TestClient):
"type": "object",
"properties": {
"description": {"title": "Description", "type": "string"},
"type": {"title": "Type", "type": "string", "default": "plane"},
"type": {
"title": "Type",
"type": "string",
"default": "plane",
},
"size": {"title": "Size", "type": "integer"},
},
},
@ -106,7 +115,11 @@ def test_openapi_schema(client: TestClient):
"type": "object",
"properties": {
"description": {"title": "Description", "type": "string"},
"type": {"title": "Type", "type": "string", "default": "car"},
"type": {
"title": "Type",
"type": "string",
"default": "car",
},
},
},
"ValidationError": {
@ -132,10 +145,13 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
}
},
})
}
)

18
tests/test_tutorial/test_request_files/test_tutorial001_02.py

@ -59,7 +59,8 @@ def test_post_upload_file(tmp_path: Path, client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -70,7 +71,9 @@ def test_openapi_schema(client: TestClient):
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {"$ref": "#/components/schemas/Body_create_file_files__post"}
"schema": {
"$ref": "#/components/schemas/Body_create_file_files__post"
}
}
}
},
@ -99,7 +102,9 @@ def test_openapi_schema(client: TestClient):
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {"$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"}
"schema": {
"$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
}
}
}
},
@ -157,7 +162,9 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
@ -179,4 +186,5 @@ def test_openapi_schema(client: TestClient):
},
}
},
})
}
)

14
tests/test_tutorial/test_response_model/test_tutorial003.py

@ -42,7 +42,8 @@ def test_post_user(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -53,7 +54,9 @@ def test_openapi_schema(client: TestClient):
"description": "Successful Response",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/UserOut"}
"schema": {
"$ref": "#/components/schemas/UserOut"
}
}
},
},
@ -141,10 +144,13 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
}
},
})
}
)

27
tests/test_tutorial/test_response_model/test_tutorial003_01.py

@ -42,7 +42,8 @@ def test_post_user(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -63,7 +64,9 @@ def test_openapi_schema(client: TestClient):
"description": "Successful Response",
"content": {
"application/json": {
"schema": {"$ref": "#/components/schemas/BaseUser"}
"schema": {
"$ref": "#/components/schemas/BaseUser"
}
}
},
},
@ -94,13 +97,10 @@ def test_openapi_schema(client: TestClient):
"type": "string",
"format": "email",
},
"full_name":
{
"full_name": {
"title": "Full Name",
"anyOf": [{"type": "string"}, {"type": "null"}],
}
,
},
},
},
"HTTPValidationError": {
@ -110,7 +110,9 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
@ -125,12 +127,10 @@ def test_openapi_schema(client: TestClient):
"type": "string",
"format": "email",
},
"full_name":
{
"full_name": {
"title": "Full Name",
"anyOf": [{"type": "string"}, {"type": "null"}],
}
,
},
"password": {"title": "Password", "type": "string"},
},
},
@ -152,4 +152,5 @@ def test_openapi_schema(client: TestClient):
},
}
},
})
}
)

10
tests/test_tutorial/test_response_model/test_tutorial004.py

@ -50,7 +50,8 @@ def test_get(url, data, client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -134,10 +135,13 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
}
},
})
}
)

10
tests/test_tutorial/test_response_model/test_tutorial005.py

@ -40,7 +40,8 @@ def test_read_item_public_data(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -152,10 +153,13 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
}
},
})
}
)

10
tests/test_tutorial/test_response_model/test_tutorial006.py

@ -40,7 +40,8 @@ def test_read_item_public_data(client: TestClient):
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -152,10 +153,13 @@ def test_openapi_schema(client: TestClient):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
}
},
})
}
)

16
tests/test_tutorial/test_security/test_tutorial005.py

@ -215,7 +215,8 @@ def test_openapi_schema(mod: ModuleType):
client = TestClient(mod.app)
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot({
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
@ -348,7 +349,11 @@ def test_openapi_schema(mod: ModuleType):
"type": "string",
"format": "password",
},
"scope": {"title": "Scope", "type": "string", "default": ""},
"scope": {
"title": "Scope",
"type": "string",
"default": "",
},
"client_id": {
"title": "Client Id",
"anyOf": [{"type": "string"}, {"type": "null"}],
@ -383,7 +388,9 @@ def test_openapi_schema(mod: ModuleType):
"detail": {
"title": "Detail",
"type": "array",
"items": {"$ref": "#/components/schemas/ValidationError"},
"items": {
"$ref": "#/components/schemas/ValidationError"
},
}
},
},
@ -403,4 +410,5 @@ def test_openapi_schema(mod: ModuleType):
}
},
},
})
}
)

Loading…
Cancel
Save