Browse Source

Update tests for OpenAPI upload files with contentMediaType

pull/14953/head
Sebastián Ramírez 5 months ago
parent
commit
71aa01e4bf
  1. 20
      tests/test_request_params/test_file/test_list.py
  2. 8
      tests/test_request_params/test_file/test_optional.py
  3. 20
      tests/test_request_params/test_file/test_optional_list.py
  4. 16
      tests/test_request_params/test_file/test_required.py
  5. 2
      tests/test_tutorial/test_request_files/test_tutorial001.py
  6. 5
      tests/test_tutorial/test_request_files/test_tutorial001_02.py
  7. 2
      tests/test_tutorial/test_request_files/test_tutorial001_03.py
  8. 5
      tests/test_tutorial/test_request_files/test_tutorial002.py
  9. 5
      tests/test_tutorial/test_request_files/test_tutorial003.py
  10. 2
      tests/test_tutorial/test_request_forms_and_files/test_tutorial001.py

20
tests/test_request_params/test_file/test_list.py

@ -37,7 +37,10 @@ def test_list_schema(path: str):
"properties": {
"p": {
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
"title": "P",
},
},
@ -115,7 +118,10 @@ def test_list_alias_schema(path: str):
"properties": {
"p_alias": {
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
"title": "P Alias",
},
},
@ -221,7 +227,10 @@ def test_list_validation_alias_schema(path: str):
"properties": {
"p_val_alias": {
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
"title": "P Val Alias",
},
},
@ -338,7 +347,10 @@ def test_list_alias_and_validation_alias_schema(path: str):
"properties": {
"p_val_alias": {
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
"title": "P Val Alias",
},
},

8
tests/test_request_params/test_file/test_optional.py

@ -37,7 +37,7 @@ def test_optional_schema(path: str):
"properties": {
"p": {
"anyOf": [
{"type": "string", "format": "binary"},
{"type": "string", "contentMediaType": "application/octet-stream"},
{"type": "null"},
],
"title": "P",
@ -109,7 +109,7 @@ def test_optional_alias_schema(path: str):
"properties": {
"p_alias": {
"anyOf": [
{"type": "string", "format": "binary"},
{"type": "string", "contentMediaType": "application/octet-stream"},
{"type": "null"},
],
"title": "P Alias",
@ -200,7 +200,7 @@ def test_optional_validation_alias_schema(path: str):
"properties": {
"p_val_alias": {
"anyOf": [
{"type": "string", "format": "binary"},
{"type": "string", "contentMediaType": "application/octet-stream"},
{"type": "null"},
],
"title": "P Val Alias",
@ -296,7 +296,7 @@ def test_optional_alias_and_validation_alias_schema(path: str):
"properties": {
"p_val_alias": {
"anyOf": [
{"type": "string", "format": "binary"},
{"type": "string", "contentMediaType": "application/octet-stream"},
{"type": "null"},
],
"title": "P Val Alias",

20
tests/test_request_params/test_file/test_optional_list.py

@ -41,7 +41,10 @@ def test_optional_list_schema(path: str):
"anyOf": [
{
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
},
{"type": "null"},
],
@ -116,7 +119,10 @@ def test_optional_list_alias_schema(path: str):
"anyOf": [
{
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
},
{"type": "null"},
],
@ -205,7 +211,10 @@ def test_optional_validation_alias_schema(path: str):
"anyOf": [
{
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
},
{"type": "null"},
],
@ -301,7 +310,10 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
"anyOf": [
{
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
},
{"type": "null"},
],

16
tests/test_request_params/test_file/test_required.py

@ -35,7 +35,11 @@ def test_required_schema(path: str):
assert app.openapi()["components"]["schemas"][body_model_name] == {
"properties": {
"p": {"title": "P", "type": "string", "format": "binary"},
"p": {
"title": "P",
"type": "string",
"contentMediaType": "application/octet-stream",
},
},
"required": ["p"],
"title": body_model_name,
@ -109,7 +113,11 @@ def test_required_alias_schema(path: str):
assert app.openapi()["components"]["schemas"][body_model_name] == {
"properties": {
"p_alias": {"title": "P Alias", "type": "string", "format": "binary"},
"p_alias": {
"title": "P Alias",
"type": "string",
"contentMediaType": "application/octet-stream",
},
},
"required": ["p_alias"],
"title": body_model_name,
@ -216,7 +224,7 @@ def test_required_validation_alias_schema(path: str):
"p_val_alias": {
"title": "P Val Alias",
"type": "string",
"format": "binary",
"contentMediaType": "application/octet-stream",
},
},
"required": ["p_val_alias"],
@ -329,7 +337,7 @@ def test_required_alias_and_validation_alias_schema(path: str):
"p_val_alias": {
"title": "P Val Alias",
"type": "string",
"format": "binary",
"contentMediaType": "application/octet-stream",
},
},
"required": ["p_val_alias"],

2
tests/test_tutorial/test_request_files/test_tutorial001.py

@ -162,8 +162,8 @@ def test_openapi_schema(client: TestClient):
"properties": {
"file": {
"title": "File",
"contentMediaType": "application/octet-stream",
"type": "string",
"format": "binary",
}
},
},

5
tests/test_tutorial/test_request_files/test_tutorial001_02.py

@ -147,7 +147,10 @@ def test_openapi_schema(client: TestClient):
"file": {
"title": "File",
"anyOf": [
{"type": "string", "format": "binary"},
{
"type": "string",
"contentMediaType": "application/octet-stream",
},
{"type": "null"},
],
}

2
tests/test_tutorial/test_request_files/test_tutorial001_03.py

@ -134,9 +134,9 @@ def test_openapi_schema(client: TestClient):
"properties": {
"file": {
"title": "File",
"contentMediaType": "application/octet-stream",
"type": "string",
"description": "A file read as UploadFile",
"format": "binary",
}
},
},

5
tests/test_tutorial/test_request_files/test_tutorial002.py

@ -195,7 +195,10 @@ def test_openapi_schema(client: TestClient):
"files": {
"title": "Files",
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
}
},
},

5
tests/test_tutorial/test_request_files/test_tutorial003.py

@ -178,7 +178,10 @@ def test_openapi_schema(client: TestClient):
"files": {
"title": "Files",
"type": "array",
"items": {"type": "string", "format": "binary"},
"items": {
"type": "string",
"contentMediaType": "application/octet-stream",
},
"description": "Multiple files as UploadFile",
}
},

2
tests/test_tutorial/test_request_forms_and_files/test_tutorial001.py

@ -202,8 +202,8 @@ def test_openapi_schema(client: TestClient):
},
"fileb": {
"title": "Fileb",
"contentMediaType": "application/octet-stream",
"type": "string",
"format": "binary",
},
"token": {"title": "Token", "type": "string"},
},

Loading…
Cancel
Save