Browse Source

Improve test debugging (#1222)

pull/1226/head
Samuel Colvin 5 years ago
committed by GitHub
parent
commit
e9b189e9f2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      docs_src/sql_databases/sql_app/tests/test_sql_app.py
  2. 4
      tests/test_additional_properties.py
  3. 4
      tests/test_additional_response_extra.py
  4. 2
      tests/test_additional_responses_custom_validationerror.py
  5. 2
      tests/test_additional_responses_default_validationerror.py
  6. 2
      tests/test_additional_responses_response_class.py
  7. 8
      tests/test_additional_responses_router.py
  8. 6
      tests/test_application.py
  9. 4
      tests/test_custom_swagger_ui_redirect.py
  10. 12
      tests/test_dependency_cache.py
  11. 2
      tests/test_dependency_class.py
  12. 16
      tests/test_dependency_contextmanager.py
  13. 10
      tests/test_dependency_duplicates.py
  14. 4
      tests/test_empty_router.py
  15. 16
      tests/test_extra_routes.py
  16. 4
      tests/test_filter_pydantic_sub_model.py
  17. 6
      tests/test_forms_from_non_typing_sequences.py
  18. 2
      tests/test_include_route.py
  19. 20
      tests/test_infer_param_optionality.py
  20. 10
      tests/test_modules_same_name_body/test_main.py
  21. 8
      tests/test_multi_body_errors.py
  22. 6
      tests/test_multi_query_errors.py
  23. 4
      tests/test_no_swagger_ui_redirect.py
  24. 4
      tests/test_param_class.py
  25. 2
      tests/test_param_in_path_and_dependency.py
  26. 4
      tests/test_path.py
  27. 6
      tests/test_put_no_body.py
  28. 2
      tests/test_request_body_parameters_media_type.py
  29. 2
      tests/test_response_change_status_code.py
  30. 2
      tests/test_response_class_no_mediatype.py
  31. 2
      tests/test_response_code_no_body.py
  32. 10
      tests/test_response_model_sub_types.py
  33. 2
      tests/test_router_events.py
  34. 2
      tests/test_router_prefix_with_template.py
  35. 6
      tests/test_security_api_key_cookie.py
  36. 6
      tests/test_security_api_key_cookie_optional.py
  37. 6
      tests/test_security_api_key_header.py
  38. 6
      tests/test_security_api_key_header_optional.py
  39. 6
      tests/test_security_api_key_query.py
  40. 6
      tests/test_security_api_key_query_optional.py
  41. 6
      tests/test_security_http_base.py
  42. 6
      tests/test_security_http_base_optional.py
  43. 10
      tests/test_security_http_basic_optional.py
  44. 10
      tests/test_security_http_basic_realm.py
  45. 8
      tests/test_security_http_bearer.py
  46. 8
      tests/test_security_http_bearer_optional.py
  47. 8
      tests/test_security_http_digest.py
  48. 8
      tests/test_security_http_digest_optional.py
  49. 8
      tests/test_security_oauth2.py
  50. 8
      tests/test_security_oauth2_authorization_code_bearer.py
  51. 8
      tests/test_security_oauth2_optional.py
  52. 8
      tests/test_security_oauth2_password_bearer_optional.py
  53. 8
      tests/test_security_openid_connect.py
  54. 8
      tests/test_security_openid_connect_optional.py
  55. 10
      tests/test_starlette_exception.py
  56. 6
      tests/test_starlette_urlconvertors.py
  57. 2
      tests/test_sub_callbacks.py
  58. 2
      tests/test_swagger_ui_init_oauth.py
  59. 6
      tests/test_tutorial/test_additional_responses/test_tutorial001.py
  60. 6
      tests/test_tutorial/test_additional_responses/test_tutorial002.py
  61. 6
      tests/test_tutorial/test_additional_responses/test_tutorial003.py
  62. 6
      tests/test_tutorial/test_additional_responses/test_tutorial004.py
  63. 4
      tests/test_tutorial/test_additional_status_codes/test_tutorial001.py
  64. 4
      tests/test_tutorial/test_advanced_middleware/test_tutorial001.py
  65. 6
      tests/test_tutorial/test_advanced_middleware/test_tutorial002.py
  66. 4
      tests/test_tutorial/test_advanced_middleware/test_tutorial003.py
  67. 6
      tests/test_tutorial/test_async_sql_databases/test_tutorial001.py
  68. 2
      tests/test_tutorial/test_background_tasks/test_tutorial001.py
  69. 2
      tests/test_tutorial/test_background_tasks/test_tutorial002.py
  70. 8
      tests/test_tutorial/test_bigger_applications/test_main.py
  71. 4
      tests/test_tutorial/test_body/test_tutorial001.py
  72. 2
      tests/test_tutorial/test_body_fields/test_tutorial001.py
  73. 2
      tests/test_tutorial/test_body_multiple_params/test_tutorial001.py
  74. 2
      tests/test_tutorial/test_body_multiple_params/test_tutorial003.py
  75. 6
      tests/test_tutorial/test_body_nested_models/test_tutorial009.py
  76. 4
      tests/test_tutorial/test_body_updates/test_tutorial001.py
  77. 6
      tests/test_tutorial/test_cors/test_tutorial001.py
  78. 4
      tests/test_tutorial/test_custom_response/test_tutorial001b.py
  79. 4
      tests/test_tutorial/test_custom_response/test_tutorial004.py
  80. 4
      tests/test_tutorial/test_custom_response/test_tutorial005.py
  81. 2
      tests/test_tutorial/test_custom_response/test_tutorial006.py
  82. 2
      tests/test_tutorial/test_dependencies/test_tutorial001.py
  83. 2
      tests/test_tutorial/test_dependencies/test_tutorial004.py
  84. 10
      tests/test_tutorial/test_dependencies/test_tutorial006.py
  85. 4
      tests/test_tutorial/test_events/test_tutorial001.py
  86. 4
      tests/test_tutorial/test_events/test_tutorial002.py
  87. 6
      tests/test_tutorial/test_extending_openapi/test_tutorial001.py
  88. 8
      tests/test_tutorial/test_extending_openapi/test_tutorial002.py
  89. 4
      tests/test_tutorial/test_extra_data_types/test_tutorial001.py
  90. 6
      tests/test_tutorial/test_extra_models/test_tutorial003.py
  91. 4
      tests/test_tutorial/test_extra_models/test_tutorial004.py
  92. 4
      tests/test_tutorial/test_extra_models/test_tutorial005.py
  93. 6
      tests/test_tutorial/test_handling_errors/test_tutorial001.py
  94. 6
      tests/test_tutorial/test_handling_errors/test_tutorial002.py
  95. 6
      tests/test_tutorial/test_handling_errors/test_tutorial003.py
  96. 8
      tests/test_tutorial/test_handling_errors/test_tutorial004.py
  97. 6
      tests/test_tutorial/test_handling_errors/test_tutorial005.py
  98. 8
      tests/test_tutorial/test_handling_errors/test_tutorial006.py
  99. 4
      tests/test_tutorial/test_metadata/test_tutorial001.py
  100. 2
      tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py

4
docs_src/sql_databases/sql_app/tests/test_sql_app.py

@ -34,14 +34,14 @@ def test_create_user():
"/users/",
json={"email": "[email protected]", "password": "chimichangas4life"},
)
assert response.status_code == 200
assert response.status_code == 200, response.text
data = response.json()
assert data["email"] == "[email protected]"
assert "id" in data
user_id = data["id"]
response = client.get(f"/users/{user_id}")
assert response.status_code == 200
assert response.status_code == 200, response.text
data = response.json()
assert data["email"] == "[email protected]"
assert data["id"] == user_id

4
tests/test_additional_properties.py

@ -100,11 +100,11 @@ openapi_schema = {
def test_additional_properties_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_additional_properties_post():
response = client.post("/foo", json={"items": {"foo": 1, "bar": 2}})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"foo": 1, "bar": 2}

4
tests/test_additional_response_extra.py

@ -42,11 +42,11 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_path_operation():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"id": "foo"}

2
tests/test_additional_responses_custom_validationerror.py

@ -96,5 +96,5 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

2
tests/test_additional_responses_default_validationerror.py

@ -81,5 +81,5 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

2
tests/test_additional_responses_response_class.py

@ -113,5 +113,5 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

8
tests/test_additional_responses_router.py

@ -89,23 +89,23 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_a():
response = client.get("/a")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == "a"
def test_b():
response = client.get("/b")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == "b"
def test_c():
response = client.get("/c")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == "c"

6
tests/test_application.py

@ -1128,7 +1128,7 @@ def test_get_path(path, expected_status, expected_response):
def test_swagger_ui():
response = client.get("/docs")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "text/html; charset=utf-8"
assert "swagger-ui-dist" in response.text
assert (
@ -1139,13 +1139,13 @@ def test_swagger_ui():
def test_swagger_ui_oauth2_redirect():
response = client.get("/docs/oauth2-redirect")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "text/html; charset=utf-8"
assert "window.opener.swaggerUIRedirectOauth2" in response.text
def test_redoc():
response = client.get("/redoc")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "text/html; charset=utf-8"
assert "redoc@next" in response.text

4
tests/test_custom_swagger_ui_redirect.py

@ -16,7 +16,7 @@ client = TestClient(app)
def test_swagger_ui():
response = client.get("/docs")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "text/html; charset=utf-8"
assert "swagger-ui-dist" in response.text
print(client.base_url)
@ -28,7 +28,7 @@ def test_swagger_ui():
def test_swagger_ui_oauth2_redirect():
response = client.get(swagger_ui_oauth2_redirect_url)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "text/html; charset=utf-8"
assert "window.opener.swaggerUIRedirectOauth2" in response.text

12
tests/test_dependency_cache.py

@ -41,28 +41,28 @@ client = TestClient(app)
def test_normal_counter():
counter_holder["counter"] = 0
response = client.get("/counter/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"counter": 1}
response = client.get("/counter/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"counter": 2}
def test_sub_counter():
counter_holder["counter"] = 0
response = client.get("/sub-counter/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"counter": 1, "subcounter": 1}
response = client.get("/sub-counter/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"counter": 2, "subcounter": 2}
def test_sub_counter_no_cache():
counter_holder["counter"] = 0
response = client.get("/sub-counter-no-cache/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"counter": 2, "subcounter": 1}
response = client.get("/sub-counter-no-cache/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"counter": 4, "subcounter": 3}

2
tests/test_dependency_class.py

@ -66,5 +66,5 @@ client = TestClient(app)
)
def test_class_dependency(route, value):
response = client.get(route, params={"value": value})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == value

16
tests/test_dependency_contextmanager.py

@ -206,7 +206,7 @@ client = TestClient(app)
def test_async_state():
assert state["/async"] == f"asyncgen not started"
response = client.get("/async")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == f"asyncgen started"
assert state["/async"] == f"asyncgen completed"
@ -214,7 +214,7 @@ def test_async_state():
def test_sync_state():
assert state["/sync"] == f"generator not started"
response = client.get("/sync")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == f"generator started"
assert state["/sync"] == f"generator completed"
@ -237,7 +237,7 @@ def test_sync_raise_other():
def test_async_raise():
response = client.get("/async_raise")
assert response.status_code == 500
assert response.status_code == 500, response.text
assert state["/async_raise"] == "asyncgen raise finalized"
assert "/async_raise" in errors
errors.clear()
@ -272,7 +272,7 @@ def test_background_tasks():
def test_sync_raise():
response = client.get("/sync_raise")
assert response.status_code == 500
assert response.status_code == 500, response.text
assert state["/sync_raise"] == "generator raise finalized"
assert "/sync_raise" in errors
errors.clear()
@ -280,14 +280,14 @@ def test_sync_raise():
def test_sync_async_state():
response = client.get("/sync_async")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == f"asyncgen started"
assert state["/async"] == f"asyncgen completed"
def test_sync_sync_state():
response = client.get("/sync_sync")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == f"generator started"
assert state["/sync"] == f"generator completed"
@ -308,7 +308,7 @@ def test_sync_sync_raise_other():
def test_sync_async_raise():
response = client.get("/sync_async_raise")
assert response.status_code == 500
assert response.status_code == 500, response.text
assert state["/async_raise"] == "asyncgen raise finalized"
assert "/async_raise" in errors
errors.clear()
@ -316,7 +316,7 @@ def test_sync_async_raise():
def test_sync_sync_raise():
response = client.get("/sync_sync_raise")
assert response.status_code == 500
assert response.status_code == 500, response.text
assert state["/sync_raise"] == "generator raise finalized"
assert "/sync_raise" in errors
errors.clear()

10
tests/test_dependency_duplicates.py

@ -190,13 +190,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_no_duplicates_invalid():
response = client.post("/no-duplicates", json={"item": {"data": "myitem"}})
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == {
"detail": [
{
@ -213,19 +213,19 @@ def test_no_duplicates():
"/no-duplicates",
json={"item": {"data": "myitem"}, "item2": {"data": "myitem2"}},
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"data": "myitem"}, {"data": "myitem2"}]
def test_duplicates():
response = client.post("/with-duplicates", json={"data": "myitem"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"data": "myitem"}, {"data": "myitem"}]
def test_sub_duplicates():
response = client.post("/with-duplicates-sub", json={"data": "myitem"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [
{"data": "myitem"},
[{"data": "myitem"}, {"data": "myitem"}],

4
tests/test_empty_router.py

@ -21,11 +21,11 @@ client = TestClient(app)
def test_use_empty():
with client:
response = client.get("/prefix")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == ["OK"]
response = client.get("/prefix/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == ["OK"]

16
tests/test_extra_routes.py

@ -314,47 +314,47 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_api_route():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo"}
def test_get_api_route_not_decorated():
response = client.get("/items-not-decorated/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo"}
def test_delete():
response = client.delete("/items/foo", json={"name": "Foo"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo", "item": {"name": "Foo", "price": None}}
def test_head():
response = client.head("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["x-fastapi-item-id"] == "foo"
def test_options():
response = client.options("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["x-fastapi-item-id"] == "foo"
def test_patch():
response = client.patch("/items/foo", json={"name": "Foo"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo", "item": {"name": "Foo", "price": None}}
def test_trace():
response = client.request("trace", "/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "message/http"

4
tests/test_filter_pydantic_sub_model.py

@ -127,13 +127,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_filter_sub_model():
response = client.get("/model/modelA")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {
"name": "modelA",
"description": "model-a-desc",

6
tests/test_forms_from_non_typing_sequences.py

@ -26,7 +26,7 @@ def test_python_list_param_as_form():
response = client.post(
"/form/python-list", data={"items": ["first", "second", "third"]}
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == ["first", "second", "third"]
@ -34,7 +34,7 @@ def test_python_set_param_as_form():
response = client.post(
"/form/python-set", data={"items": ["first", "second", "third"]}
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert set(response.json()) == {"first", "second", "third"}
@ -42,5 +42,5 @@ def test_python_tuple_param_as_form():
response = client.post(
"/form/python-tuple", data={"items": ["first", "second", "third"]}
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == ["first", "second", "third"]

2
tests/test_include_route.py

@ -18,5 +18,5 @@ client = TestClient(app)
def test_sub_router():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"hello": "world"}

20
tests/test_infer_param_optionality.py

@ -46,21 +46,21 @@ client = TestClient(app)
def test_get_users():
"""Check that /users returns expected data"""
response = client.get("/users")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"user_id": "u1"}, {"user_id": "u2"}]
def test_get_user():
"""Check that /users/{user_id} returns expected data"""
response = client.get("/users/abc123")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"user_id": "abc123"}
def test_get_items_1():
"""Check that /items returns expected data"""
response = client.get("/items")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [
{"item_id": "i1", "user_id": "u1"},
{"item_id": "i2", "user_id": "u2"},
@ -70,42 +70,42 @@ def test_get_items_1():
def test_get_items_2():
"""Check that /items returns expected data with user_id specified"""
response = client.get("/items?user_id=abc123")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"item_id": "i2", "user_id": "abc123"}]
def test_get_item_1():
"""Check that /items/{item_id} returns expected data"""
response = client.get("/items/item01")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "item01"}
def test_get_item_2():
"""Check that /items/{item_id} returns expected data with user_id specified"""
response = client.get("/items/item01?user_id=abc123")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "item01", "user_id": "abc123"}
def test_get_users_items():
"""Check that /users/{user_id}/items returns expected data"""
response = client.get("/users/abc123/items")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"item_id": "i2", "user_id": "abc123"}]
def test_get_users_item():
"""Check that /users/{user_id}/items returns expected data"""
response = client.get("/users/abc123/items/item01")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "item01", "user_id": "abc123"}
def test_schema_1():
"""Check that the user_id is a required path parameter under /users"""
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
r = response.json()
d = {
@ -122,7 +122,7 @@ def test_schema_1():
def test_schema_2():
"""Check that the user_id is an optional query parameter under /items"""
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
r = response.json()
d = {

10
tests/test_modules_same_name_body/test_main.py

@ -125,31 +125,31 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_post_a():
data = {"a": 2, "b": "foo"}
response = client.post("/a/compute", json=data)
assert response.status_code == 200
assert response.status_code == 200, response.text
data = response.json()
def test_post_a_invalid():
data = {"a": "bar", "b": "foo"}
response = client.post("/a/compute", json=data)
assert response.status_code == 422
assert response.status_code == 422, response.text
def test_post_b():
data = {"a": 2, "b": "foo"}
response = client.post("/b/compute/", json=data)
assert response.status_code == 200
assert response.status_code == 200, response.text
data = response.json()
def test_post_b_invalid():
data = {"a": "bar", "b": "foo"}
response = client.post("/b/compute/", json=data)
assert response.status_code == 422
assert response.status_code == 422, response.text

8
tests/test_multi_body_errors.py

@ -139,23 +139,23 @@ multiple_errors = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_put_correct_body():
response = client.post("/items/", json=[{"name": "Foo", "age": 5}])
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item": [{"name": "Foo", "age": 5}]}
def test_jsonable_encoder_requiring_error():
response = client.post("/items/", json=[{"name": "Foo", "age": -1.0}])
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == single_error
def test_put_incorrect_body_multiple():
response = client.post("/items/", json=[{"age": "five"}, {"age": "six"}])
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == multiple_errors

6
tests/test_multi_query_errors.py

@ -102,17 +102,17 @@ multiple_errors = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_multi_query():
response = client.get("/items/?q=5&q=6")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"q": [5, 6]}
def test_multi_query_incorrect():
response = client.get("/items/?q=five&q=six")
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == multiple_errors

4
tests/test_no_swagger_ui_redirect.py

@ -14,7 +14,7 @@ client = TestClient(app)
def test_swagger_ui():
response = client.get("/docs")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["content-type"] == "text/html; charset=utf-8"
assert "swagger-ui-dist" in response.text
print(client.base_url)
@ -23,7 +23,7 @@ def test_swagger_ui():
def test_swagger_ui_no_oauth2_redirect():
response = client.get("/docs/oauth2-redirect")
assert response.status_code == 404
assert response.status_code == 404, response.text
def test_response():

4
tests/test_param_class.py

@ -15,11 +15,11 @@ client = TestClient(app)
def test_default_param_query_none():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"q": None}
def test_default_param_query():
response = client.get("/items/?q=foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"q": "foo"}

2
tests/test_param_in_path_and_dependency.py

@ -90,4 +90,4 @@ def test_reused_param():
def test_read_users():
response = client.get("/users/42")
assert response.status_code == 200
assert response.status_code == 200, response.text

4
tests/test_path.py

@ -8,13 +8,13 @@ client = TestClient(app)
def test_text_get():
response = client.get("/text")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == "Hello World"
def test_nonexistent():
response = client.get("/nonexistent")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.json() == {"detail": "Not Found"}

6
tests/test_put_no_body.py

@ -81,17 +81,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_put_no_body():
response = client.put("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo"}
def test_put_no_body_with_body():
response = client.put("/items/foo", json={"name": "Foo"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo"}

2
tests/test_request_body_parameters_media_type.py

@ -55,7 +55,7 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
openapi_schema = response.json()
assert (
openapi_schema["paths"]["/products"]["post"]["requestBody"]

2
tests/test_response_change_status_code.py

@ -22,5 +22,5 @@ client = TestClient(app)
def test_dependency_set_status_code():
response = client.get("/")
assert response.status_code == 201
assert response.status_code == 201, response.text
assert response.json() == {"msg": "Hello World"}

2
tests/test_response_class_no_mediatype.py

@ -110,5 +110,5 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

2
tests/test_response_code_no_body.py

@ -104,5 +104,5 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

10
tests/test_response_model_sub_types.py

@ -145,16 +145,16 @@ client = TestClient(app)
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_path_operations():
response = client.get("/valid1")
assert response.status_code == 200
assert response.status_code == 200, response.text
response = client.get("/valid2")
assert response.status_code == 200
assert response.status_code == 200, response.text
response = client.get("/valid3")
assert response.status_code == 200
assert response.status_code == 200, response.text
response = client.get("/valid4")
assert response.status_code == 200
assert response.status_code == 200, response.text

2
tests/test_router_events.py

@ -77,7 +77,7 @@ def test_router_events():
assert state.router_shutdown is False
assert state.sub_router_shutdown is False
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert state.app_startup is True
assert state.router_startup is True

2
tests/test_router_prefix_with_template.py

@ -19,5 +19,5 @@ client = TestClient(app)
def test_get():
response = client.get("/seg/users/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"segment": "seg", "id": "foo"}

6
tests/test_security_api_key_cookie.py

@ -52,17 +52,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_api_key():
response = client.get("/users/me", cookies={"key": "secret"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "secret"}
def test_security_api_key_no_key():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}

6
tests/test_security_api_key_cookie_optional.py

@ -59,17 +59,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_api_key():
response = client.get("/users/me", cookies={"key": "secret"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "secret"}
def test_security_api_key_no_key():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

6
tests/test_security_api_key_header.py

@ -52,17 +52,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_api_key():
response = client.get("/users/me", headers={"key": "secret"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "secret"}
def test_security_api_key_no_key():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}

6
tests/test_security_api_key_header_optional.py

@ -58,17 +58,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_api_key():
response = client.get("/users/me", headers={"key": "secret"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "secret"}
def test_security_api_key_no_key():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

6
tests/test_security_api_key_query.py

@ -52,17 +52,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_api_key():
response = client.get("/users/me?key=secret")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "secret"}
def test_security_api_key_no_key():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}

6
tests/test_security_api_key_query_optional.py

@ -58,17 +58,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_api_key():
response = client.get("/users/me?key=secret")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "secret"}
def test_security_api_key_no_key():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

6
tests/test_security_http_base.py

@ -40,17 +40,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_base():
response = client.get("/users/me", headers={"Authorization": "Other foobar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"scheme": "Other", "credentials": "foobar"}
def test_security_http_base_no_credentials():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}

6
tests/test_security_http_base_optional.py

@ -46,17 +46,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_base():
response = client.get("/users/me", headers={"Authorization": "Other foobar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"scheme": "Other", "credentials": "foobar"}
def test_security_http_base_no_credentials():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

10
tests/test_security_http_basic_optional.py

@ -46,20 +46,20 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_basic():
auth = HTTPBasicAuth(username="john", password="secret")
response = client.get("/users/me", auth=auth)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "john", "password": "secret"}
def test_security_http_basic_no_credentials():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}
@ -67,7 +67,7 @@ def test_security_http_basic_invalid_credentials():
response = client.get(
"/users/me", headers={"Authorization": "Basic notabase64token"}
)
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == "Basic"
assert response.json() == {"detail": "Invalid authentication credentials"}
@ -76,6 +76,6 @@ def test_security_http_basic_non_basic_credentials():
payload = b64encode(b"johnsecret").decode("ascii")
auth_header = f"Basic {payload}"
response = client.get("/users/me", headers={"Authorization": auth_header})
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == "Basic"
assert response.json() == {"detail": "Invalid authentication credentials"}

10
tests/test_security_http_basic_realm.py

@ -43,21 +43,21 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_basic():
auth = HTTPBasicAuth(username="john", password="secret")
response = client.get("/users/me", auth=auth)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "john", "password": "secret"}
def test_security_http_basic_no_credentials():
response = client.get("/users/me")
assert response.json() == {"detail": "Not authenticated"}
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
@ -65,7 +65,7 @@ def test_security_http_basic_invalid_credentials():
response = client.get(
"/users/me", headers={"Authorization": "Basic notabase64token"}
)
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
assert response.json() == {"detail": "Invalid authentication credentials"}
@ -74,6 +74,6 @@ def test_security_http_basic_non_basic_credentials():
payload = b64encode(b"johnsecret").decode("ascii")
auth_header = f"Basic {payload}"
response = client.get("/users/me", headers={"Authorization": auth_header})
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.headers["WWW-Authenticate"] == 'Basic realm="simple"'
assert response.json() == {"detail": "Invalid authentication credentials"}

8
tests/test_security_http_bearer.py

@ -40,23 +40,23 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_bearer():
response = client.get("/users/me", headers={"Authorization": "Bearer foobar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"scheme": "Bearer", "credentials": "foobar"}
def test_security_http_bearer_no_credentials():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}
def test_security_http_bearer_incorrect_scheme_credentials():
response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}

8
tests/test_security_http_bearer_optional.py

@ -46,23 +46,23 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_bearer():
response = client.get("/users/me", headers={"Authorization": "Bearer foobar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"scheme": "Bearer", "credentials": "foobar"}
def test_security_http_bearer_no_credentials():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}
def test_security_http_bearer_incorrect_scheme_credentials():
response = client.get("/users/me", headers={"Authorization": "Basic notreally"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

8
tests/test_security_http_digest.py

@ -40,19 +40,19 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_digest():
response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"scheme": "Digest", "credentials": "foobar"}
def test_security_http_digest_no_credentials():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}
@ -60,5 +60,5 @@ def test_security_http_digest_incorrect_scheme_credentials():
response = client.get(
"/users/me", headers={"Authorization": "Other invalidauthorization"}
)
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}

8
tests/test_security_http_digest_optional.py

@ -46,19 +46,19 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_http_digest():
response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"scheme": "Digest", "credentials": "foobar"}
def test_security_http_digest_no_credentials():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}
@ -66,5 +66,5 @@ def test_security_http_digest_incorrect_scheme_credentials():
response = client.get(
"/users/me", headers={"Authorization": "Other invalidauthorization"}
)
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Invalid authentication credentials"}

8
tests/test_security_oauth2.py

@ -156,25 +156,25 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_oauth2():
response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Bearer footokenbar"}
def test_security_oauth2_password_other_header():
response = client.get("/users/me", headers={"Authorization": "Other footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Other footokenbar"}
def test_security_oauth2_password_bearer_no_header():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}

8
tests/test_security_oauth2_authorization_code_bearer.py

@ -55,23 +55,23 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_no_token():
response = client.get("/items")
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Not authenticated"}
def test_incorrect_token():
response = client.get("/items", headers={"Authorization": "Non-existent testtoken"})
assert response.status_code == 401
assert response.status_code == 401, response.text
assert response.json() == {"detail": "Not authenticated"}
def test_token():
response = client.get("/items", headers={"Authorization": "Bearer testtoken"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"token": "testtoken"}

8
tests/test_security_oauth2_optional.py

@ -160,25 +160,25 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_oauth2():
response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Bearer footokenbar"}
def test_security_oauth2_password_other_header():
response = client.get("/users/me", headers={"Authorization": "Other footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Other footokenbar"}
def test_security_oauth2_password_bearer_no_header():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

8
tests/test_security_oauth2_password_bearer_optional.py

@ -49,23 +49,23 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_no_token():
response = client.get("/items")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}
def test_token():
response = client.get("/items", headers={"Authorization": "Bearer testtoken"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"token": "testtoken"}
def test_incorrect_token():
response = client.get("/items", headers={"Authorization": "Notexistent testtoken"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

8
tests/test_security_openid_connect.py

@ -52,23 +52,23 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_oauth2():
response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Bearer footokenbar"}
def test_security_oauth2_password_other_header():
response = client.get("/users/me", headers={"Authorization": "Other footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Other footokenbar"}
def test_security_oauth2_password_bearer_no_header():
response = client.get("/users/me")
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "Not authenticated"}

8
tests/test_security_openid_connect_optional.py

@ -58,23 +58,23 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_security_oauth2():
response = client.get("/users/me", headers={"Authorization": "Bearer footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Bearer footokenbar"}
def test_security_oauth2_password_other_header():
response = client.get("/users/me", headers={"Authorization": "Other footokenbar"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"username": "Other footokenbar"}
def test_security_oauth2_password_bearer_no_header():
response = client.get("/users/me")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Create an account first"}

10
tests/test_starlette_exception.py

@ -126,31 +126,31 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_item():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item": "The Foo Wrestlers"}
def test_get_item_not_found():
response = client.get("/items/bar")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.headers.get("x-error") == "Some custom header"
assert response.json() == {"detail": "Item not found"}
def test_get_starlette_item():
response = client.get("/starlette-items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item": "The Foo Wrestlers"}
def test_get_starlette_item_not_found():
response = client.get("/starlette-items/bar")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.headers.get("x-error") is None
assert response.json() == {"detail": "Item not found"}

6
tests/test_starlette_urlconvertors.py

@ -25,7 +25,7 @@ client = TestClient(app)
def test_route_converters_int():
# Test integer conversion
response = client.get("/int/5")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"int": 5}
assert app.url_path_for("int_convertor", param=5) == "/int/5"
@ -33,7 +33,7 @@ def test_route_converters_int():
def test_route_converters_float():
# Test float conversion
response = client.get("/float/25.5")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"float": 25.5}
assert app.url_path_for("float_convertor", param=25.5) == "/float/25.5"
@ -41,7 +41,7 @@ def test_route_converters_float():
def test_route_converters_path():
# Test path conversion
response = client.get("/path/some/example")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"path": "some/example"}

2
tests/test_sub_callbacks.py

@ -221,7 +221,7 @@ def test_get():
response = client.post(
"/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Invoice received"}

2
tests/test_swagger_ui_init_oauth.py

@ -16,7 +16,7 @@ client = TestClient(app)
def test_swagger_ui():
response = client.get("/docs")
assert response.status_code == 200
assert response.status_code == 200, response.text
print(response.text)
assert f"ui.initOAuth" in response.text
assert f'"appName": "The Predendapp"' in response.text

6
tests/test_tutorial/test_additional_responses/test_tutorial001.py

@ -100,17 +100,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_path_operation():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"id": "foo", "value": "there goes my hero"}
def test_path_operation_not_found():
response = client.get("/items/bar")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.json() == {"message": "Item not found"}

6
tests/test_tutorial/test_additional_responses/test_tutorial002.py

@ -96,20 +96,20 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_path_operation():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"id": "foo", "value": "there goes my hero"}
def test_path_operation_img():
shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
response = client.get("/items/foo?img=1")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["Content-Type"] == "image/png"
assert len(response.content)
os.remove("./image.png")

6
tests/test_tutorial/test_additional_responses/test_tutorial003.py

@ -101,17 +101,17 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_path_operation():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"id": "foo", "value": "there goes my hero"}
def test_path_operation_not_found():
response = client.get("/items/bar")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.json() == {"message": "Item not found"}

6
tests/test_tutorial/test_additional_responses/test_tutorial004.py

@ -99,20 +99,20 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_path_operation():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"id": "foo", "value": "there goes my hero"}
def test_path_operation_img():
shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
response = client.get("/items/foo?img=1")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.headers["Content-Type"] == "image/png"
assert len(response.content)
os.remove("./image.png")

4
tests/test_tutorial/test_additional_status_codes/test_tutorial001.py

@ -7,11 +7,11 @@ client = TestClient(app)
def test_update():
response = client.put("/items/foo", json={"name": "Wrestlers"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"name": "Wrestlers", "size": None}
def test_create():
response = client.put("/items/red", json={"name": "Chillies"})
assert response.status_code == 201
assert response.status_code == 201, response.text
assert response.json() == {"name": "Chillies", "size": None}

4
tests/test_tutorial/test_advanced_middleware/test_tutorial001.py

@ -6,9 +6,9 @@ from advanced_middleware.tutorial001 import app
def test_middleware():
client = TestClient(app, base_url="https://testserver")
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text
client = TestClient(app)
response = client.get("/", allow_redirects=False)
assert response.status_code == 307
assert response.status_code == 307, response.text
assert response.headers["location"] == "https://testserver/"

6
tests/test_tutorial/test_advanced_middleware/test_tutorial002.py

@ -6,10 +6,10 @@ from advanced_middleware.tutorial002 import app
def test_middleware():
client = TestClient(app, base_url="http://example.com")
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text
client = TestClient(app, base_url="http://subdomain.example.com")
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text
client = TestClient(app, base_url="http://invalidhost")
response = client.get("/")
assert response.status_code == 400
assert response.status_code == 400, response.text

4
tests/test_tutorial/test_advanced_middleware/test_tutorial003.py

@ -14,9 +14,9 @@ client = TestClient(app)
def test_middleware():
response = client.get("/large", headers={"accept-encoding": "gzip"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.text == "x" * 4000
assert response.headers["Content-Encoding"] == "gzip"
assert int(response.headers["Content-Length"]) < 4000
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text

6
tests/test_tutorial/test_async_sql_databases/test_tutorial001.py

@ -113,7 +113,7 @@ openapi_schema = {
def test_openapi_schema():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
@ -121,11 +121,11 @@ def test_create_read():
with TestClient(app) as client:
note = {"text": "Foo bar", "completed": False}
response = client.post("/notes/", json=note)
assert response.status_code == 200
assert response.status_code == 200, response.text
data = response.json()
assert data["text"] == note["text"]
assert data["completed"] == note["completed"]
assert "id" in data
response = client.get(f"/notes/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert data in response.json()

2
tests/test_tutorial/test_background_tasks/test_tutorial001.py

@ -13,7 +13,7 @@ def test():
if log.is_file():
os.remove(log) # pragma: no cover
response = client.post("/send-notification/[email protected]")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"message": "Notification sent in the background"}
with open("./log.txt") as f:
assert "notification for [email protected]: some notification" in f.read()

2
tests/test_tutorial/test_background_tasks/test_tutorial002.py

@ -13,7 +13,7 @@ def test():
if log.is_file():
os.remove(log) # pragma: no cover
response = client.post("/send-notification/[email protected]?q=some-query")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"message": "Message sent"}
with open("./log.txt") as f:
assert "found query: some-query\nmessage to [email protected]" in f.read()

8
tests/test_tutorial/test_bigger_applications/test_main.py

@ -270,7 +270,7 @@ def test_get_path(path, expected_status, expected_response, headers):
def test_put_no_header():
response = client.put("/items/foo")
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == {
"detail": [
{
@ -284,17 +284,17 @@ def test_put_no_header():
def test_put_invalid_header():
response = client.put("/items/foo", headers={"X-Token": "invalid"})
assert response.status_code == 400
assert response.status_code == 400, response.text
assert response.json() == {"detail": "X-Token header invalid"}
def test_put():
response = client.put("/items/foo", headers={"X-Token": "fake-super-secret-token"})
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": "foo", "name": "The Fighters"}
def test_put_forbidden():
response = client.put("/items/bar", headers={"X-Token": "fake-super-secret-token"})
assert response.status_code == 403
assert response.status_code == 403, response.text
assert response.json() == {"detail": "You can only update the item: foo"}

4
tests/test_tutorial/test_body/test_tutorial001.py

@ -85,7 +85,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
@ -176,5 +176,5 @@ def test_post_body(path, body, expected_status, expected_response):
def test_post_broken_body():
response = client.post("/items/", data={"name": "Foo", "price": 50.5})
assert response.status_code == 400
assert response.status_code == 400, response.text
assert response.json() == {"detail": "There was an error parsing the body"}

2
tests/test_tutorial/test_body_fields/test_tutorial001.py

@ -120,7 +120,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

2
tests/test_tutorial/test_body_multiple_params/test_tutorial001.py

@ -103,7 +103,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

2
tests/test_tutorial/test_body_multiple_params/test_tutorial003.py

@ -114,7 +114,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

6
tests/test_tutorial/test_body_nested_models/test_tutorial009.py

@ -77,21 +77,21 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_post_body():
data = {"2": 2.2, "3": 3.3}
response = client.post("/index-weights/", json=data)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == data
def test_post_invalid_body():
data = {"foo": 2.2, "3": 3.3}
response = client.post("/index-weights/", json=data)
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == {
"detail": [
{

4
tests/test_tutorial/test_body_updates/test_tutorial001.py

@ -133,13 +133,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get():
response = client.get("/items/baz")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {
"name": "Baz",
"description": None,

6
tests/test_tutorial/test_cors/test_tutorial001.py

@ -12,7 +12,7 @@ def test_cors():
"Access-Control-Request-Headers": "X-Example",
}
response = client.options("/", headers=headers)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.text == "OK"
assert (
response.headers["access-control-allow-origin"]
@ -23,7 +23,7 @@ def test_cors():
# Test standard response
headers = {"Origin": "https://localhost.tiangolo.com"}
response = client.get("/", headers=headers)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert (
response.headers["access-control-allow-origin"]
@ -32,6 +32,6 @@ def test_cors():
# Test non-CORS response
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"message": "Hello World"}
assert "access-control-allow-origin" not in response.headers

4
tests/test_tutorial/test_custom_response/test_tutorial001b.py

@ -26,11 +26,11 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_custom_response():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"item_id": "Foo"}]

4
tests/test_tutorial/test_custom_response/test_tutorial004.py

@ -37,11 +37,11 @@ html_contents = """
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_custom_response():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.text == html_contents

4
tests/test_tutorial/test_custom_response/test_tutorial005.py

@ -26,11 +26,11 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get():
response = client.get("/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.text == "Hello World"

2
tests/test_tutorial/test_custom_response/test_tutorial006.py

@ -7,5 +7,5 @@ client = TestClient(app)
def test_get():
response = client.get("/typer", allow_redirects=False)
assert response.status_code == 307
assert response.status_code == 307, response.text
assert response.headers["location"] == "https://typer.tiangolo.com"

2
tests/test_tutorial/test_dependencies/test_tutorial001.py

@ -128,7 +128,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

2
tests/test_tutorial/test_dependencies/test_tutorial004.py

@ -86,7 +86,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema

10
tests/test_tutorial/test_dependencies/test_tutorial006.py

@ -79,13 +79,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_no_headers():
response = client.get("/items/")
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == {
"detail": [
{
@ -104,7 +104,7 @@ def test_get_no_headers():
def test_get_invalid_one_header():
response = client.get("/items/", headers={"X-Token": "invalid"})
assert response.status_code == 400
assert response.status_code == 400, response.text
assert response.json() == {"detail": "X-Token header invalid"}
@ -112,7 +112,7 @@ def test_get_invalid_second_header():
response = client.get(
"/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
)
assert response.status_code == 400
assert response.status_code == 400, response.text
assert response.json() == {"detail": "X-Key header invalid"}
@ -124,5 +124,5 @@ def test_get_valid_headers():
"X-Key": "fake-super-secret-key",
},
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"item": "Foo"}, {"item": "Bar"}]

4
tests/test_tutorial/test_events/test_tutorial001.py

@ -72,8 +72,8 @@ openapi_schema = {
def test_events():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"name": "Fighters"}

4
tests/test_tutorial/test_events/test_tutorial002.py

@ -25,10 +25,10 @@ openapi_schema = {
def test_events():
with TestClient(app) as client:
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"name": "Foo"}]
with open("log.txt") as log:
assert "Application shutdown" in log.read()

6
tests/test_tutorial/test_extending_openapi/test_tutorial001.py

@ -31,14 +31,14 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"name": "Foo"}]

8
tests/test_tutorial/test_extending_openapi/test_tutorial002.py

@ -19,24 +19,24 @@ def client():
def test_swagger_ui_html(client: TestClient):
response = client.get("/docs")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert "/static/swagger-ui-bundle.js" in response.text
assert "/static/swagger-ui.css" in response.text
def test_swagger_ui_oauth2_redirect_html(client: TestClient):
response = client.get("/docs/oauth2-redirect")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert "window.opener.swaggerUIRedirectOauth2" in response.text
def test_redoc_html(client: TestClient):
response = client.get("/redoc")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert "/static/redoc.standalone.js" in response.text
def test_api(client: TestClient):
response = client.get("/users/john")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json()["message"] == "Hello john"

4
tests/test_tutorial/test_extra_data_types/test_tutorial001.py

@ -113,7 +113,7 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
@ -134,5 +134,5 @@ def test_extra_types():
}
)
response = client.put(f"/items/{item_id}", json=data)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == expected_response

6
tests/test_tutorial/test_extra_models/test_tutorial003.py

@ -102,13 +102,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_car():
response = client.get("/items/item1")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {
"description": "All my friends drive a low rider",
"type": "car",
@ -117,7 +117,7 @@ def test_get_car():
def test_get_plane():
response = client.get("/items/item2")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {
"description": "Music is my aeroplane, it's my aeroplane",
"type": "plane",

4
tests/test_tutorial/test_extra_models/test_tutorial004.py

@ -47,13 +47,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_items():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [
{"name": "Foo", "description": "There comes my hero"},
{"name": "Red", "description": "It's my aeroplane"},

4
tests/test_tutorial/test_extra_models/test_tutorial005.py

@ -34,11 +34,11 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_items():
response = client.get("/keyword-weights/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"foo": 2.3, "bar": 3.4}

6
tests/test_tutorial/test_handling_errors/test_tutorial001.py

@ -73,18 +73,18 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_item():
response = client.get("/items/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item": "The Foo Wrestlers"}
def test_get_item_not_found():
response = client.get("/items/bar")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.headers.get("x-error") is None
assert response.json() == {"detail": "Item not found"}

6
tests/test_tutorial/test_handling_errors/test_tutorial002.py

@ -73,18 +73,18 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_item_header():
response = client.get("/items-header/foo")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item": "The Foo Wrestlers"}
def test_get_item_not_found_header():
response = client.get("/items-header/bar")
assert response.status_code == 404
assert response.status_code == 404, response.text
assert response.headers.get("x-error") == "There goes my error"
assert response.json() == {"detail": "Item not found"}

6
tests/test_tutorial/test_handling_errors/test_tutorial003.py

@ -73,19 +73,19 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get():
response = client.get("/unicorns/shinny")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"unicorn_name": "shinny"}
def test_get_exception():
response = client.get("/unicorns/yolo")
assert response.status_code == 418
assert response.status_code == 418, response.text
assert response.json() == {
"message": "Oops! yolo did something. There goes a rainbow..."
}

8
tests/test_tutorial/test_handling_errors/test_tutorial004.py

@ -73,13 +73,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_validation_error():
response = client.get("/items/foo")
assert response.status_code == 400
assert response.status_code == 400, response.text
validation_error_str_lines = [
b"1 validation error for Request",
b"path -> item_id",
@ -90,11 +90,11 @@ def test_get_validation_error():
def test_get_http_error():
response = client.get("/items/3")
assert response.status_code == 418
assert response.status_code == 418, response.text
assert response.content == b"Nope! I don't like 3."
def test_get():
response = client.get("/items/2")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": 2}

6
tests/test_tutorial/test_handling_errors/test_tutorial005.py

@ -82,13 +82,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_post_validation_error():
response = client.post("/items/", json={"title": "towel", "size": "XL"})
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == {
"detail": [
{
@ -104,5 +104,5 @@ def test_post_validation_error():
def test_post():
data = {"title": "towel", "size": 5}
response = client.post("/items/", json=data)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == data

8
tests/test_tutorial/test_handling_errors/test_tutorial006.py

@ -73,13 +73,13 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_get_validation_error():
response = client.get("/items/foo")
assert response.status_code == 422
assert response.status_code == 422, response.text
assert response.json() == {
"detail": [
{
@ -93,11 +93,11 @@ def test_get_validation_error():
def test_get_http_error():
response = client.get("/items/3")
assert response.status_code == 418
assert response.status_code == 418, response.text
assert response.json() == {"detail": "Nope! I don't like 3."}
def test_get():
response = client.get("/items/2")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"item_id": 2}

4
tests/test_tutorial/test_metadata/test_tutorial001.py

@ -30,11 +30,11 @@ openapi_schema = {
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == openapi_schema
def test_items():
response = client.get("/items/")
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == [{"name": "Foo"}]

2
tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py

@ -165,7 +165,7 @@ def test_get():
response = client.post(
"/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
)
assert response.status_code == 200
assert response.status_code == 200, response.text
assert response.json() == {"msg": "Invoice received"}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save