From 010f551cb651e7aab4891ad53e41bb79855ab26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pito=C5=84?= Date: Wed, 8 Nov 2023 11:05:23 +0100 Subject: [PATCH] Python 3.12 support, dependency update (#1129) --- .github/workflows/benchmark.yml | 2 +- .github/workflows/tests.yml | 4 +- CHANGELOG.md | 6 + pyproject.toml | 5 +- tests/asgi/__snapshots__/test_explorer.ambr | 296 +++++++++++ .../__snapshots__/test_query_execution.ambr | 122 +++++ .../test_request_data_reading.ambr | 22 + tests/asgi/snapshots/__init__.py | 0 tests/asgi/snapshots/snap_test_explorer.py | 290 ----------- .../snapshots/snap_test_query_execution.py | 116 ----- .../snap_test_request_data_reading.py | 22 - tests/asgi/test_explorer.py | 10 +- tests/asgi/test_query_execution.py | 28 +- tests/asgi/test_request_data_reading.py | 14 +- .../__snapshots__/test_explorers.ambr | 466 ++++++++++++++++++ tests/explorers/snapshots/__init__.py | 0 .../snapshots/snap_test_explorers.py | 455 ----------------- tests/explorers/test_explorers.py | 12 +- .../__snapshots__/test_apollotracing.ambr | 69 +++ tests/tracing/snapshots/__init__.py | 0 .../snapshots/snap_test_apollotracing.py | 72 --- .../snapshots/snap_test_apollotracing_sync.py | 40 -- tests/tracing/test_apollotracing.py | 8 +- .../test_explorer.ambr} | 52 +- .../__snapshots__/test_query_execution.ambr | 89 ++++ .../test_request_data_reading.ambr | 64 +++ tests/wsgi/conftest.py | 2 +- tests/wsgi/snapshots/__init__.py | 0 .../snapshots/snap_test_query_execution.py | 86 ---- .../snap_test_request_data_reading.py | 60 --- tests/wsgi/test_explorer.py | 10 +- tests/wsgi/test_query_execution.py | 2 +- tests/wsgi/test_request_data_reading.py | 18 +- tests_integrations/fastapi/requirements.txt | 25 +- tests_integrations/flask/requirements.txt | 8 +- tests_integrations/starlette/requirements.txt | 4 +- 36 files changed, 1241 insertions(+), 1238 deletions(-) create mode 100644 tests/asgi/__snapshots__/test_explorer.ambr create mode 100644 tests/asgi/__snapshots__/test_query_execution.ambr create mode 100644 tests/asgi/__snapshots__/test_request_data_reading.ambr delete mode 100644 tests/asgi/snapshots/__init__.py delete mode 100644 tests/asgi/snapshots/snap_test_explorer.py delete mode 100644 tests/asgi/snapshots/snap_test_query_execution.py delete mode 100644 tests/asgi/snapshots/snap_test_request_data_reading.py create mode 100644 tests/explorers/__snapshots__/test_explorers.ambr delete mode 100644 tests/explorers/snapshots/__init__.py delete mode 100644 tests/explorers/snapshots/snap_test_explorers.py create mode 100644 tests/tracing/__snapshots__/test_apollotracing.ambr delete mode 100644 tests/tracing/snapshots/__init__.py delete mode 100644 tests/tracing/snapshots/snap_test_apollotracing.py delete mode 100644 tests/tracing/snapshots/snap_test_apollotracing_sync.py rename tests/wsgi/{snapshots/snap_test_explorer.py => __snapshots__/test_explorer.ambr} (92%) create mode 100644 tests/wsgi/__snapshots__/test_query_execution.ambr create mode 100644 tests/wsgi/__snapshots__/test_request_data_reading.ambr delete mode 100644 tests/wsgi/snapshots/__init__.py delete mode 100644 tests/wsgi/snapshots/snap_test_query_execution.py delete mode 100644 tests/wsgi/snapshots/snap_test_request_data_reading.py diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8042f58e2..c644f5e66 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false max-parallel: 1 matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c7b98d91b..5c2ddf883 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 @@ -48,7 +48,7 @@ jobs: fail-fast: false matrix: library: ["fastapi", "starlette", "flask"] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 849a3bae3..c5e5161cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 0.22 (UNRELEASED) + +- Added Python 3.12 to tested versions. +- Updated integration tests to run against FastAPI 0.104, Flask 3.0 and Starlette 0.32. + + ## 0.21 (2023-06-27) - Updated the GraphiQL template with working explorer plugin URL. diff --git a/pyproject.toml b/pyproject.toml index f54ad8113..a7dcb8ba0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "ariadne" -version = "0.20.1" +version = "0.21" description = "Ariadne is a Python library for implementing GraphQL servers." authors = [{ name = "Mirumee Software", email = "hello@mirumee.com" }] readme = "README.md" @@ -19,6 +19,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ @@ -36,7 +37,7 @@ test = [ "pytest-cov", "pytest-mock", "freezegun", - "snapshottest", + "syrupy", "werkzeug", "httpx", "opentracing", diff --git a/tests/asgi/__snapshots__/test_explorer.ambr b/tests/asgi/__snapshots__/test_explorer.ambr new file mode 100644 index 000000000..2b23961d3 --- /dev/null +++ b/tests/asgi/__snapshots__/test_explorer.ambr @@ -0,0 +1,296 @@ +# serializer version: 1 +# name: test_405_bad_method_is_served_on_get_request_for_disabled_explorer + '' +# --- +# name: test_apollo_html_is_served_on_get_request + ''' + + + + + + Ariadne GraphQL + + + +
+ + + + + + ''' +# --- +# name: test_default_explorer_html_is_served_on_get_request + ''' + + + + + + + Ariadne GraphQL + + + + + + +
+
Loading Ariadne GraphQL...
+
+ + + + + + + + + + + + + ''' +# --- +# name: test_graphiql_html_is_served_on_get_request + ''' + + + + + + + Ariadne GraphQL + + + + + + +
+
Loading Ariadne GraphQL...
+
+ + + + + + + + + + + + + ''' +# --- +# name: test_playground_html_is_served_on_get_request + ''' + + + + + + Ariadne GraphQL + + + + + +
+ + +
Loading + Ariadne GraphQL +
+
+ + + + + ''' +# --- diff --git a/tests/asgi/__snapshots__/test_query_execution.ambr b/tests/asgi/__snapshots__/test_query_execution.ambr new file mode 100644 index 000000000..37029df30 --- /dev/null +++ b/tests/asgi/__snapshots__/test_query_execution.ambr @@ -0,0 +1,122 @@ +# serializer version: 1 +# name: test_attempt_execute_complex_query_without_variables_returns_error_json + dict({ + 'data': None, + 'errors': list([ + dict({ + 'locations': list([ + dict({ + 'column': 18, + 'line': 2, + }), + ]), + 'message': "Variable '$name' of required type 'String!' was not provided.", + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_invalid_operation_name_string_returns_error_json + dict({ + 'data': None, + 'errors': list([ + dict({ + 'message': "Unknown operation named 'otherOperation'.", + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_invalid_operation_name_type_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': '"[1, 2, 3]" is not a valid operation name.', + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_invalid_variables_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': 'Query variables must be a null or an object.', + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_non_string_query_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': 'The query must be a string.', + }), + ]), + }) +# --- +# name: test_attempt_execute_query_without_query_entry_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': 'The query must be a string.', + }), + ]), + }) +# --- +# name: test_attempt_execute_subscription_with_invalid_query_returns_error_json + dict({ + 'locations': list([ + dict({ + 'column': 16, + 'line': 1, + }), + ]), + 'message': "Cannot query field 'error' on type 'Subscription'.", + }) +# --- +# name: test_attempt_execute_subscription_with_invalid_query_returns_error_json_graphql_transport_ws + list([ + dict({ + 'locations': list([ + dict({ + 'column': 16, + 'line': 1, + }), + ]), + 'message': "Cannot query field 'error' on type 'Subscription'.", + }), + ]) +# --- +# name: test_complex_query_is_executed_for_post_json_request + dict({ + 'data': dict({ + 'hello': 'Hello, Bob!', + }), + }) +# --- +# name: test_complex_query_without_operation_name_executes_successfully + dict({ + 'data': dict({ + 'hello': 'Hello, Bob!', + }), + }) +# --- +# name: test_query_is_executed_for_multipart_form_request_with_file + dict({ + 'data': dict({ + 'upload': 'UploadFile', + }), + }) +# --- +# name: test_query_is_executed_for_multipart_request_with_large_file_with_tracing + dict({ + 'data': dict({ + 'upload': 'UploadFile', + }), + }) +# --- +# name: test_query_is_executed_for_post_json_request + dict({ + 'data': dict({ + 'status': True, + }), + }) +# --- diff --git a/tests/asgi/__snapshots__/test_request_data_reading.ambr b/tests/asgi/__snapshots__/test_request_data_reading.ambr new file mode 100644 index 000000000..918e02286 --- /dev/null +++ b/tests/asgi/__snapshots__/test_request_data_reading.ambr @@ -0,0 +1,22 @@ +# serializer version: 1 +# name: test_attempt_parse_json_array_request_raises_graphql_bad_request_error + '{"errors":[{"message":"Operation data should be a JSON object"}]}' +# --- +# name: test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error + '{"errors":[{"message":"Operation data should be a JSON object"}]}' +# --- +# name: test_attempt_parse_non_json_request_body_raises_bad_request_error + 'Request body is not a valid JSON' +# --- +# name: test_attempt_parse_non_json_request_raises_bad_request_error + 'Posted content must be of type application/json or multipart/form-data' +# --- +# name: test_attempt_parse_request_missing_content_type_raises_bad_request_error + 'Posted content must be of type application/json or multipart/form-data' +# --- +# name: test_multipart_form_request_fails_if_map_is_not_valid_json + b"Request 'map' multipart field is not a valid JSON" +# --- +# name: test_multipart_form_request_fails_if_operations_is_not_valid_json + b"Request 'operations' multipart field is not a valid JSON" +# --- diff --git a/tests/asgi/snapshots/__init__.py b/tests/asgi/snapshots/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/asgi/snapshots/snap_test_explorer.py b/tests/asgi/snapshots/snap_test_explorer.py deleted file mode 100644 index 742da3d6c..000000000 --- a/tests/asgi/snapshots/snap_test_explorer.py +++ /dev/null @@ -1,290 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_405_bad_method_is_served_on_get_request_for_disabled_explorer 1'] = '' - -snapshots['test_apollo_html_is_served_on_get_request 1'] = ''' - - - - - Ariadne GraphQL - - - -
- - - - -''' - -snapshots['test_default_explorer_html_is_served_on_get_request 1'] = ''' - - - - - - Ariadne GraphQL - - - - - - -
-
Loading Ariadne GraphQL...
-
- - - - - - - - - - - -''' - -snapshots['test_graphiql_html_is_served_on_get_request 1'] = ''' - - - - - - Ariadne GraphQL - - - - - - -
-
Loading Ariadne GraphQL...
-
- - - - - - - - - - - -''' - -snapshots['test_playground_html_is_served_on_get_request 1'] = ''' - - - - - Ariadne GraphQL - - - - - -
- - -
Loading - Ariadne GraphQL -
-
- - - -''' diff --git a/tests/asgi/snapshots/snap_test_query_execution.py b/tests/asgi/snapshots/snap_test_query_execution.py deleted file mode 100644 index 855b9dea6..000000000 --- a/tests/asgi/snapshots/snap_test_query_execution.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_attempt_execute_complex_query_without_variables_returns_error_json 1'] = { - 'data': None, - 'errors': [ - { - 'locations': [ - { - 'column': 18, - 'line': 2 - } - ], - 'message': "Variable '$name' of required type 'String!' was not provided." - } - ] -} - -snapshots['test_attempt_execute_query_with_invalid_operation_name_string_returns_error_json 1'] = { - 'data': None, - 'errors': [ - { - 'message': "Unknown operation named 'otherOperation'." - } - ] -} - -snapshots['test_attempt_execute_query_with_invalid_operation_name_type_returns_error_json 1'] = { - 'errors': [ - { - 'message': '"[1, 2, 3]" is not a valid operation name.' - } - ] -} - -snapshots['test_attempt_execute_query_with_invalid_variables_returns_error_json 1'] = { - 'errors': [ - { - 'message': 'Query variables must be a null or an object.' - } - ] -} - -snapshots['test_attempt_execute_query_with_non_string_query_returns_error_json 1'] = { - 'errors': [ - { - 'message': 'The query must be a string.' - } - ] -} - -snapshots['test_attempt_execute_query_without_query_entry_returns_error_json 1'] = { - 'errors': [ - { - 'message': 'The query must be a string.' - } - ] -} - -snapshots['test_attempt_execute_subscription_with_invalid_query_returns_error_json 1'] = { - 'locations': [ - { - 'column': 16, - 'line': 1 - } - ], - 'message': "Cannot query field 'error' on type 'Subscription'." -} - -snapshots['test_attempt_execute_subscription_with_invalid_query_returns_error_json_graphql_transport_ws 1'] = [ - { - 'locations': [ - { - 'column': 16, - 'line': 1 - } - ], - 'message': "Cannot query field 'error' on type 'Subscription'." - } -] - -snapshots['test_complex_query_is_executed_for_post_json_request 1'] = { - 'data': { - 'hello': 'Hello, Bob!' - } -} - -snapshots['test_complex_query_without_operation_name_executes_successfully 1'] = { - 'data': { - 'hello': 'Hello, Bob!' - } -} - -snapshots['test_query_is_executed_for_multipart_form_request_with_file 1'] = { - 'data': { - 'upload': 'UploadFile' - } -} - -snapshots['test_query_is_executed_for_multipart_request_with_large_file_with_tracing 1'] = { - 'data': { - 'upload': 'UploadFile' - } -} - -snapshots['test_query_is_executed_for_post_json_request 1'] = { - 'data': { - 'status': True - } -} diff --git a/tests/asgi/snapshots/snap_test_request_data_reading.py b/tests/asgi/snapshots/snap_test_request_data_reading.py deleted file mode 100644 index dfbd8ea0a..000000000 --- a/tests/asgi/snapshots/snap_test_request_data_reading.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_attempt_parse_json_array_request_raises_graphql_bad_request_error 1'] = '{"errors":[{"message":"Operation data should be a JSON object"}]}' - -snapshots['test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error 1'] = '{"errors":[{"message":"Operation data should be a JSON object"}]}' - -snapshots['test_attempt_parse_non_json_request_body_raises_bad_request_error 1'] = 'Request body is not a valid JSON' - -snapshots['test_attempt_parse_non_json_request_raises_bad_request_error 1'] = 'Posted content must be of type application/json or multipart/form-data' - -snapshots['test_attempt_parse_request_missing_content_type_raises_bad_request_error 1'] = 'Posted content must be of type application/json or multipart/form-data' - -snapshots['test_multipart_form_request_fails_if_map_is_not_valid_json 1'] = b"Request 'map' multipart field is not a valid JSON" - -snapshots['test_multipart_form_request_fails_if_operations_is_not_valid_json 1'] = b"Request 'operations' multipart field is not a valid JSON" diff --git a/tests/asgi/test_explorer.py b/tests/asgi/test_explorer.py index e402c2296..147095427 100644 --- a/tests/asgi/test_explorer.py +++ b/tests/asgi/test_explorer.py @@ -14,7 +14,7 @@ def test_default_explorer_html_is_served_on_get_request(schema, snapshot): client = TestClient(app) response = client.get("/") assert response.status_code == 200 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_apollo_html_is_served_on_get_request(schema, snapshot): @@ -22,7 +22,7 @@ def test_apollo_html_is_served_on_get_request(schema, snapshot): client = TestClient(app) response = client.get("/") assert response.status_code == 200 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_graphiql_html_is_served_on_get_request(schema, snapshot): @@ -30,7 +30,7 @@ def test_graphiql_html_is_served_on_get_request(schema, snapshot): client = TestClient(app) response = client.get("/") assert response.status_code == 200 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_playground_html_is_served_on_get_request(schema, snapshot): @@ -38,7 +38,7 @@ def test_playground_html_is_served_on_get_request(schema, snapshot): client = TestClient(app) response = client.get("/") assert response.status_code == 200 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_405_bad_method_is_served_on_get_request_for_disabled_explorer( @@ -48,4 +48,4 @@ def test_405_bad_method_is_served_on_get_request_for_disabled_explorer( client = TestClient(app) response = client.get("/") assert response.status_code == 405 - snapshot.assert_match(response.text) + assert snapshot == response.text diff --git a/tests/asgi/test_query_execution.py b/tests/asgi/test_query_execution.py index a6209fee4..910e5bae7 100644 --- a/tests/asgi/test_query_execution.py +++ b/tests/asgi/test_query_execution.py @@ -23,7 +23,7 @@ def test_query_is_executed_for_post_json_request(client, snapshot): response = client.post("/", json={"query": "{ status }"}) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_complex_query_is_executed_for_post_json_request(client, snapshot): @@ -36,13 +36,13 @@ def test_complex_query_is_executed_for_post_json_request(client, snapshot): }, ) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_complex_query_without_operation_name_executes_successfully(client, snapshot): response = client.post("/", json={"query": complex_query, "variables": variables}) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_complex_query_without_variables_returns_error_json( @@ -52,13 +52,13 @@ def test_attempt_execute_complex_query_without_variables_returns_error_json( "/", json={"query": complex_query, "operationName": operation_name} ) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_query_without_query_entry_returns_error_json(client, snapshot): response = client.post("/", json={"variables": variables}) assert response.status_code == 400 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_query_with_non_string_query_returns_error_json( @@ -66,7 +66,7 @@ def test_attempt_execute_query_with_non_string_query_returns_error_json( ): response = client.post("/", json={"query": {"test": "error"}}) assert response.status_code == 400 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_query_with_invalid_variables_returns_error_json( @@ -74,7 +74,7 @@ def test_attempt_execute_query_with_invalid_variables_returns_error_json( ): response = client.post("/", json={"query": complex_query, "variables": "invalid"}) assert response.status_code == 400 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_query_with_invalid_operation_name_string_returns_error_json( @@ -89,7 +89,7 @@ def test_attempt_execute_query_with_invalid_operation_name_string_returns_error_ }, ) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_query_with_invalid_operation_name_type_returns_error_json( @@ -104,7 +104,7 @@ def test_attempt_execute_query_with_invalid_operation_name_type_returns_error_js }, ) assert response.status_code == 400 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_attempt_execute_subscription_with_invalid_query_returns_error_json( @@ -123,7 +123,7 @@ def test_attempt_execute_subscription_with_invalid_query_returns_error_json( assert response["type"] == GraphQLWSHandler.GQL_CONNECTION_ACK response = ws.receive_json() assert response["type"] == GraphQLWSHandler.GQL_ERROR - snapshot.assert_match(response["payload"]) + assert snapshot == response["payload"] def test_attempt_execute_subscription_with_invalid_query_returns_error_json_graphql_transport_ws( @@ -144,7 +144,7 @@ def test_attempt_execute_subscription_with_invalid_query_returns_error_json_grap assert response["type"] == GraphQLTransportWSHandler.GQL_CONNECTION_ACK response = ws.receive_json() assert response["type"] == GraphQLTransportWSHandler.GQL_ERROR - snapshot.assert_match(response["payload"]) + assert snapshot == response["payload"] def test_query_is_executed_for_multipart_form_request_with_file( @@ -164,7 +164,7 @@ def test_query_is_executed_for_multipart_form_request_with_file( files={"0": ("test.txt", "hello".encode("utf-8"))}, ) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() def test_query_is_executed_for_multipart_request_with_large_file_with_tracing( @@ -184,7 +184,7 @@ def test_query_is_executed_for_multipart_request_with_large_file_with_tracing( files={"0": ("test_2.txt", b"\0" * 1024 * 1024)}, ) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() class CustomExtension(Extension): @@ -219,4 +219,4 @@ def test_schema_not_set(client, snapshot): }, ) assert response.status_code == 200 - snapshot.assert_match(response.json()) + assert snapshot == response.json() diff --git a/tests/asgi/test_request_data_reading.py b/tests/asgi/test_request_data_reading.py index af10b9477..3a86e3aab 100644 --- a/tests/asgi/test_request_data_reading.py +++ b/tests/asgi/test_request_data_reading.py @@ -6,13 +6,13 @@ def test_attempt_parse_request_missing_content_type_raises_bad_request_error( ): response = client.post("/", content="") assert response.status_code == 400 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_attempt_parse_non_json_request_raises_bad_request_error(client, snapshot): response = client.post("/", content="", headers={"content-type": "text/plain"}) assert response.status_code == 400 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_attempt_parse_non_json_request_body_raises_bad_request_error(client, snapshot): @@ -20,7 +20,7 @@ def test_attempt_parse_non_json_request_body_raises_bad_request_error(client, sn "/", content="", headers={"content-type": "application/json"} ) assert response.status_code == 400 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error( @@ -28,7 +28,7 @@ def test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error( ): response = client.post("/", json="json string") assert response.status_code == 400 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_attempt_parse_json_array_request_raises_graphql_bad_request_error( @@ -36,7 +36,7 @@ def test_attempt_parse_json_array_request_raises_graphql_bad_request_error( ): response = client.post("/", json=[1, 2, 3]) assert response.status_code == 400 - snapshot.assert_match(response.text) + assert snapshot == response.text def test_multipart_form_request_fails_if_operations_is_not_valid_json(client, snapshot): @@ -49,7 +49,7 @@ def test_multipart_form_request_fails_if_operations_is_not_valid_json(client, sn files={"0": ("test.txt", "hello".encode("utf-8"))}, ) assert response.status_code == 400 - snapshot.assert_match(response.content) + assert snapshot == response.content def test_multipart_form_request_fails_if_map_is_not_valid_json(client, snapshot): @@ -67,4 +67,4 @@ def test_multipart_form_request_fails_if_map_is_not_valid_json(client, snapshot) files={"0": ("test.txt", "hello".encode("utf-8"))}, ) assert response.status_code == 400 - snapshot.assert_match(response.content) + assert snapshot == response.content diff --git a/tests/explorers/__snapshots__/test_explorers.ambr b/tests/explorers/__snapshots__/test_explorers.ambr new file mode 100644 index 000000000..477a3d883 --- /dev/null +++ b/tests/explorers/__snapshots__/test_explorers.ambr @@ -0,0 +1,466 @@ +# serializer version: 1 +# name: test_apollo_explorer_produces_html + ''' + + + + + + Ariadne GraphQL + + + +
+ + + + + + ''' +# --- +# name: test_graphiql_explorer_includes_explorer_plugin + ''' + + + + + + + Ariadne GraphQL + + + + + + + + +
+
Loading Ariadne GraphQL...
+
+ + + + + + + + + + + + + + + ''' +# --- +# name: test_graphiql_explorer_produces_html + ''' + + + + + + + Ariadne GraphQL + + + + + + +
+
Loading Ariadne GraphQL...
+
+ + + + + + + + + + + + + ''' +# --- +# name: test_graphiql_explorer_with_custom_subscription_url + ''' + + + + + + + Ariadne GraphQL + + + + + + +
+
Loading Ariadne GraphQL...
+
+ + + + + + + + + + + + + ''' +# --- +# name: test_playground_explorer_produces_html + ''' + + + + + + Ariadne GraphQL + + + + + +
+ + +
Loading + Ariadne GraphQL +
+
+ + + + + ''' +# --- +# name: test_playground_explorer_produces_html_with_settings + ''' + + + + + + Hello world! + + + + + +
+ + +
Loading + Hello world! +
+
+ + + + + ''' +# --- diff --git a/tests/explorers/snapshots/__init__.py b/tests/explorers/snapshots/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/explorers/snapshots/snap_test_explorers.py b/tests/explorers/snapshots/snap_test_explorers.py deleted file mode 100644 index a5de6fc2d..000000000 --- a/tests/explorers/snapshots/snap_test_explorers.py +++ /dev/null @@ -1,455 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_apollo_explorer_produces_html 1'] = ''' - - - - - Ariadne GraphQL - - - -
- - - - -''' - -snapshots['test_graphiql_explorer_includes_explorer_plugin 1'] = ''' - - - - - - Ariadne GraphQL - - - - - - - - -
-
Loading Ariadne GraphQL...
-
- - - - - - - - - - - - - -''' - -snapshots['test_graphiql_explorer_with_custom_subscription_url 1'] = ''' - - - - - - Ariadne GraphQL - - - - - - -
-
Loading Ariadne GraphQL...
-
- - - - - - - - - - - -''' - -snapshots['test_graphiql_explorer_produces_html 1'] = ''' - - - - - - Ariadne GraphQL - - - - - - -
-
Loading Ariadne GraphQL...
-
- - - - - - - - - - - -''' - -snapshots['test_playground_explorer_produces_html 1'] = ''' - - - - - Ariadne GraphQL - - - - - -
- - -
Loading - Ariadne GraphQL -
-
- - - -''' - -snapshots['test_playground_explorer_produces_html_with_settings 1'] = ''' - - - - - Hello world! - - - - - -
- - -
Loading - Hello world! -
-
- - - -''' diff --git a/tests/explorers/test_explorers.py b/tests/explorers/test_explorers.py index fbf35b4e5..dd82f9b07 100644 --- a/tests/explorers/test_explorers.py +++ b/tests/explorers/test_explorers.py @@ -8,27 +8,27 @@ def test_apollo_explorer_produces_html(snapshot): explorer = ExplorerApollo() - snapshot.assert_match(explorer.html(None)) + assert snapshot == explorer.html(None) def test_graphiql_explorer_produces_html(snapshot): explorer = ExplorerGraphiQL() - snapshot.assert_match(explorer.html(None)) + assert snapshot == explorer.html(None) def test_graphiql_explorer_includes_explorer_plugin(snapshot): explorer = ExplorerGraphiQL(explorer_plugin=True) - snapshot.assert_match(explorer.html(None)) + assert snapshot == explorer.html(None) def test_graphiql_explorer_with_custom_subscription_url(snapshot): explorer = ExplorerGraphiQL(subscription_url="ws://custom_url") - snapshot.assert_match(explorer.html(None)) + assert snapshot == explorer.html(None) def test_playground_explorer_produces_html(snapshot): explorer = ExplorerPlayground() - snapshot.assert_match(explorer.html(None)) + assert snapshot == explorer.html(None) def test_playground_explorer_produces_html_with_settings(snapshot): @@ -53,7 +53,7 @@ def test_playground_explorer_produces_html_with_settings(snapshot): tracing_tracing_supported=True, query_plan_hide_query_plan_response=True, ) - snapshot.assert_match(explorer.html(None)) + assert snapshot == explorer.html(None) def test_http_405_explorer_doesnt_produce_html(): diff --git a/tests/tracing/__snapshots__/test_apollotracing.ambr b/tests/tracing/__snapshots__/test_apollotracing.ambr new file mode 100644 index 000000000..d81caa923 --- /dev/null +++ b/tests/tracing/__snapshots__/test_apollotracing.ambr @@ -0,0 +1,69 @@ +# serializer version: 1 +# name: test_apollotracing_extension_adds_tracing_data_to_async_result_extensions + dict({ + 'data': dict({ + 'status': True, + }), + 'extensions': dict({ + 'tracing': dict({ + 'duration': 0, + 'endTime': '2012-01-14T03:21:34.000000Z', + 'execution': dict({ + 'resolvers': list([ + dict({ + 'duration': 0, + 'fieldName': 'status', + 'parentType': 'Query', + 'path': list([ + 'status', + ]), + 'returnType': 'Boolean', + 'startOffset': 0, + }), + ]), + }), + 'startTime': '2012-01-14T03:21:34.000000Z', + 'version': 1, + }), + }), + }) +# --- +# name: test_apollotracing_extension_adds_tracing_data_to_sync_result_extensions + dict({ + 'data': dict({ + 'status': True, + }), + 'extensions': dict({ + 'tracing': dict({ + 'duration': 0, + 'endTime': '2012-01-14T03:21:34.000000Z', + 'execution': dict({ + 'resolvers': list([ + dict({ + 'duration': 0, + 'fieldName': 'status', + 'parentType': 'Query', + 'path': list([ + 'status', + ]), + 'returnType': 'Boolean', + 'startOffset': 0, + }), + ]), + }), + 'startTime': '2012-01-14T03:21:34.000000Z', + 'version': 1, + }), + }), + }) +# --- +# name: test_apollotracing_extension_handles_exceptions_in_resolvers_in_async_context + dict({ + 'testError': None, + }) +# --- +# name: test_apollotracing_extension_handles_exceptions_in_resolvers_in_sync_context + dict({ + 'testError': None, + }) +# --- diff --git a/tests/tracing/snapshots/__init__.py b/tests/tracing/snapshots/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/tracing/snapshots/snap_test_apollotracing.py b/tests/tracing/snapshots/snap_test_apollotracing.py deleted file mode 100644 index 5b2db1369..000000000 --- a/tests/tracing/snapshots/snap_test_apollotracing.py +++ /dev/null @@ -1,72 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_apollotracing_extension_adds_tracing_data_to_async_result_extensions 1'] = { - 'data': { - 'status': True - }, - 'extensions': { - 'tracing': { - 'duration': 0, - 'endTime': '2012-01-14T03:21:34.000000Z', - 'execution': { - 'resolvers': [ - { - 'duration': 0, - 'fieldName': 'status', - 'parentType': 'Query', - 'path': [ - 'status' - ], - 'returnType': 'Boolean', - 'startOffset': 0 - } - ] - }, - 'startTime': '2012-01-14T03:21:34.000000Z', - 'version': 1 - } - } -} - -snapshots['test_apollotracing_extension_adds_tracing_data_to_sync_result_extensions 1'] = { - 'data': { - 'status': True - }, - 'extensions': { - 'tracing': { - 'duration': 0, - 'endTime': '2012-01-14T03:21:34.000000Z', - 'execution': { - 'resolvers': [ - { - 'duration': 0, - 'fieldName': 'status', - 'parentType': 'Query', - 'path': [ - 'status' - ], - 'returnType': 'Boolean', - 'startOffset': 0 - } - ] - }, - 'startTime': '2012-01-14T03:21:34.000000Z', - 'version': 1 - } - } -} - -snapshots['test_apollotracing_extension_handles_exceptions_in_resolvers_in_async_context 1'] = { - 'testError': None -} - -snapshots['test_apollotracing_extension_handles_exceptions_in_resolvers_in_sync_context 1'] = { - 'testError': None -} diff --git a/tests/tracing/snapshots/snap_test_apollotracing_sync.py b/tests/tracing/snapshots/snap_test_apollotracing_sync.py deleted file mode 100644 index d844dc325..000000000 --- a/tests/tracing/snapshots/snap_test_apollotracing_sync.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_apollotracing_extension_adds_tracing_data_to_result_extensions 1'] = { - 'data': { - 'status': True - }, - 'extensions': { - 'tracing': { - 'duration': 0, - 'endTime': '2012-01-14T03:21:34.000000Z', - 'execution': { - 'resolvers': [ - { - 'duration': 0, - 'fieldName': 'status', - 'parentType': 'Query', - 'path': [ - 'status' - ], - 'returnType': 'Boolean', - 'startOffset': 0 - } - ] - }, - 'startTime': '2012-01-14T03:21:34.000000Z', - 'version': 1 - } - } -} - -snapshots['test_apollotracing_extension_handles_exceptions_in_resolvers 1'] = { - 'testError': None -} diff --git a/tests/tracing/test_apollotracing.py b/tests/tracing/test_apollotracing.py index e462e945e..0859e96e6 100644 --- a/tests/tracing/test_apollotracing.py +++ b/tests/tracing/test_apollotracing.py @@ -38,7 +38,7 @@ async def test_apollotracing_extension_adds_tracing_data_to_async_result_extensi _, result = await graphql( async_schema, {"query": "{ status }"}, extensions=[ApolloTracingExtension] ) - snapshot.assert_match(result) + assert snapshot == result @freeze_time("2012-01-14 03:21:34") @@ -48,7 +48,7 @@ def test_apollotracing_extension_adds_tracing_data_to_sync_result_extensions( _, result = graphql_sync( schema, {"query": "{ status }"}, extensions=[ApolloTracingExtension] ) - snapshot.assert_match(result) + assert snapshot == result @freeze_time("2012-01-14 03:21:34") @@ -59,7 +59,7 @@ async def test_apollotracing_extension_handles_exceptions_in_resolvers_in_async_ _, result = await graphql( async_schema, {"query": "{ testError }"}, extensions=[ApolloTracingExtension] ) - snapshot.assert_match(result["data"]) + assert snapshot == result["data"] @freeze_time("2012-01-14 03:21:34") @@ -69,7 +69,7 @@ def test_apollotracing_extension_handles_exceptions_in_resolvers_in_sync_context _, result = graphql_sync( schema, {"query": "{ testError }"}, extensions=[ApolloTracingExtension] ) - snapshot.assert_match(result["data"]) + assert snapshot == result["data"] @pytest.mark.asyncio diff --git a/tests/wsgi/snapshots/snap_test_explorer.py b/tests/wsgi/__snapshots__/test_explorer.ambr similarity index 92% rename from tests/wsgi/snapshots/snap_test_explorer.py rename to tests/wsgi/__snapshots__/test_explorer.ambr index d2bddb13f..2941db4a2 100644 --- a/tests/wsgi/snapshots/snap_test_explorer.py +++ b/tests/wsgi/__snapshots__/test_explorer.ambr @@ -1,27 +1,25 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_405_bad_method_is_served_on_get_request_for_disabled_explorer 1'] = [ -] - -snapshots['test_apollo_html_is_served_on_get_request 1'] = [ - b'\n\n \n \n \n Ariadne GraphQL\n \n \n \n
\n \n \n \n\n' -] - -snapshots['test_default_explorer_html_is_served_on_get_request 1'] = [ - b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' -] - -snapshots['test_graphiql_html_is_served_on_get_request 1'] = [ - b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n' -] - -snapshots['test_playground_html_is_served_on_get_request 1'] = [ - b'\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n \n
\n \n \'\'\n
Loading\n Ariadne GraphQL\n
\n
\n \n \n\n' -] +# serializer version: 1 +# name: test_405_bad_method_is_served_on_get_request_for_disabled_explorer + list([ + ]) +# --- +# name: test_apollo_html_is_served_on_get_request + list([ + b'\n\n \n \n \n Ariadne GraphQL\n \n \n \n
\n \n \n \n\n', + ]) +# --- +# name: test_default_explorer_html_is_served_on_get_request + list([ + b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n', + ]) +# --- +# name: test_graphiql_html_is_served_on_get_request + list([ + b'\n\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n\n \n
\n
Loading Ariadne GraphQL...
\n
\n\n \n \n\n \n\n \n\n \n \n\n', + ]) +# --- +# name: test_playground_html_is_served_on_get_request + list([ + b'\n\n \n \n \n Ariadne GraphQL\n \n \n \n \n \n
\n \n \'\'\n
Loading\n Ariadne GraphQL\n
\n
\n \n \n\n', + ]) +# --- diff --git a/tests/wsgi/__snapshots__/test_query_execution.ambr b/tests/wsgi/__snapshots__/test_query_execution.ambr new file mode 100644 index 000000000..08ba44326 --- /dev/null +++ b/tests/wsgi/__snapshots__/test_query_execution.ambr @@ -0,0 +1,89 @@ +# serializer version: 1 +# name: test_attempt_execute_complex_query_without_variables_returns_error_json + dict({ + 'data': None, + 'errors': list([ + dict({ + 'locations': list([ + dict({ + 'column': 18, + 'line': 2, + }), + ]), + 'message': "Variable '$name' of required type 'String!' was not provided.", + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_invalid_operation_name_string_returns_error_json + dict({ + 'data': None, + 'errors': list([ + dict({ + 'message': "Unknown operation named 'otherOperation'.", + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_invalid_operation_name_type_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': '"[1, 2, 3]" is not a valid operation name.', + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_invalid_variables_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': 'Query variables must be a null or an object.', + }), + ]), + }) +# --- +# name: test_attempt_execute_query_with_non_string_query_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': 'The query must be a string.', + }), + ]), + }) +# --- +# name: test_attempt_execute_query_without_query_entry_returns_error_json + dict({ + 'errors': list([ + dict({ + 'message': 'The query must be a string.', + }), + ]), + }) +# --- +# name: test_complex_query_is_executed_for_post_json_request + dict({ + 'data': dict({ + 'hello': 'Hello, Bob!', + }), + }) +# --- +# name: test_complex_query_without_operation_name_executes_successfully + dict({ + 'data': dict({ + 'hello': 'Hello, Bob!', + }), + }) +# --- +# name: test_query_is_executed_for_multipart_form_request_with_file + list([ + b'{"data": {"upload": "File"}}', + ]) +# --- +# name: test_query_is_executed_for_post_json_request + dict({ + 'data': dict({ + 'status': True, + }), + }) +# --- diff --git a/tests/wsgi/__snapshots__/test_request_data_reading.ambr b/tests/wsgi/__snapshots__/test_request_data_reading.ambr new file mode 100644 index 000000000..af82ee398 --- /dev/null +++ b/tests/wsgi/__snapshots__/test_request_data_reading.ambr @@ -0,0 +1,64 @@ +# serializer version: 1 +# name: test_attempt_get_content_length_from_malformed_header_raises_bad_request_error + list([ + b'Content length header is missing or incorrect', + ]) +# --- +# name: test_attempt_get_content_length_from_missing_header_raises_bad_request_error + list([ + b'Content length header is missing or incorrect', + ]) +# --- +# name: test_attempt_get_request_body_from_empty_wsgi_input_raises_bad_request_error + list([ + b'Request body cannot be empty', + ]) +# --- +# name: test_attempt_get_request_body_from_missing_wsgi_input_raises_bad_request_error + list([ + b'Request body cannot be empty', + ]) +# --- +# name: test_attempt_parse_json_array_request_raises_graphql_bad_request_error + dict({ + 'errors': list([ + dict({ + 'message': 'Operation data should be a JSON object', + }), + ]), + }) +# --- +# name: test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error + dict({ + 'errors': list([ + dict({ + 'message': 'Operation data should be a JSON object', + }), + ]), + }) +# --- +# name: test_attempt_parse_non_json_request_body_raises_bad_request_error + list([ + b'Request body is not a valid JSON', + ]) +# --- +# name: test_attempt_parse_non_json_request_raises_bad_request_error + list([ + b'Posted content must be of type application/json or multipart/form-data', + ]) +# --- +# name: test_attempt_parse_request_missing_content_type_raises_bad_request_error + list([ + b'Posted content must be of type application/json or multipart/form-data', + ]) +# --- +# name: test_multipart_form_request_fails_if_map_is_not_valid_json + list([ + b"Request 'map' multipart field is not a valid JSON", + ]) +# --- +# name: test_multipart_form_request_fails_if_operations_is_not_valid_json + list([ + b"Request 'operations' multipart field is not a valid JSON", + ]) +# --- diff --git a/tests/wsgi/conftest.py b/tests/wsgi/conftest.py index 9190bb858..fe543a9a0 100644 --- a/tests/wsgi/conftest.py +++ b/tests/wsgi/conftest.py @@ -93,6 +93,6 @@ def wrapped_graphql_query_request_factory( def assert_json_response_equals_snapshot(snapshot): def assertion(reponse): deserialized_data = json.loads(reponse[0].decode("utf-8")) - snapshot.assert_match(deserialized_data) + assert snapshot == deserialized_data return assertion diff --git a/tests/wsgi/snapshots/__init__.py b/tests/wsgi/snapshots/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/wsgi/snapshots/snap_test_query_execution.py b/tests/wsgi/snapshots/snap_test_query_execution.py deleted file mode 100644 index 796195929..000000000 --- a/tests/wsgi/snapshots/snap_test_query_execution.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_attempt_execute_complex_query_without_variables_returns_error_json 1'] = { - 'data': None, - 'errors': [ - { - 'locations': [ - { - 'column': 18, - 'line': 2 - } - ], - 'message': "Variable '$name' of required type 'String!' was not provided." - } - ] -} - -snapshots['test_attempt_execute_query_with_invalid_operation_name_string_returns_error_json 1'] = { - 'data': None, - 'errors': [ - { - 'message': "Unknown operation named 'otherOperation'." - } - ] -} - -snapshots['test_attempt_execute_query_with_invalid_operation_name_type_returns_error_json 1'] = { - 'errors': [ - { - 'message': '"[1, 2, 3]" is not a valid operation name.' - } - ] -} - -snapshots['test_attempt_execute_query_with_invalid_variables_returns_error_json 1'] = { - 'errors': [ - { - 'message': 'Query variables must be a null or an object.' - } - ] -} - -snapshots['test_attempt_execute_query_with_non_string_query_returns_error_json 1'] = { - 'errors': [ - { - 'message': 'The query must be a string.' - } - ] -} - -snapshots['test_attempt_execute_query_without_query_entry_returns_error_json 1'] = { - 'errors': [ - { - 'message': 'The query must be a string.' - } - ] -} - -snapshots['test_complex_query_is_executed_for_post_json_request 1'] = { - 'data': { - 'hello': 'Hello, Bob!' - } -} - -snapshots['test_complex_query_without_operation_name_executes_successfully 1'] = { - 'data': { - 'hello': 'Hello, Bob!' - } -} - -snapshots['test_query_is_executed_for_multipart_form_request_with_file 1'] = [ - b'{"data": {"upload": "File"}}' -] - -snapshots['test_query_is_executed_for_post_json_request 1'] = { - 'data': { - 'status': True - } -} diff --git a/tests/wsgi/snapshots/snap_test_request_data_reading.py b/tests/wsgi/snapshots/snap_test_request_data_reading.py deleted file mode 100644 index 76acf74b9..000000000 --- a/tests/wsgi/snapshots/snap_test_request_data_reading.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# snapshottest: v1 - https://goo.gl/zC4yUc -from __future__ import unicode_literals - -from snapshottest import Snapshot - - -snapshots = Snapshot() - -snapshots['test_attempt_get_content_length_from_malformed_header_raises_bad_request_error 1'] = [ - b'Content length header is missing or incorrect' -] - -snapshots['test_attempt_get_content_length_from_missing_header_raises_bad_request_error 1'] = [ - b'Content length header is missing or incorrect' -] - -snapshots['test_attempt_get_request_body_from_empty_wsgi_input_raises_bad_request_error 1'] = [ - b'Request body cannot be empty' -] - -snapshots['test_attempt_get_request_body_from_missing_wsgi_input_raises_bad_request_error 1'] = [ - b'Request body cannot be empty' -] - -snapshots['test_attempt_parse_json_array_request_raises_graphql_bad_request_error 1'] = { - 'errors': [ - { - 'message': 'Operation data should be a JSON object' - } - ] -} - -snapshots['test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error 1'] = { - 'errors': [ - { - 'message': 'Operation data should be a JSON object' - } - ] -} - -snapshots['test_attempt_parse_non_json_request_body_raises_bad_request_error 1'] = [ - b'Request body is not a valid JSON' -] - -snapshots['test_attempt_parse_non_json_request_raises_bad_request_error 1'] = [ - b'Posted content must be of type application/json or multipart/form-data' -] - -snapshots['test_attempt_parse_request_missing_content_type_raises_bad_request_error 1'] = [ - b'Posted content must be of type application/json or multipart/form-data' -] - -snapshots['test_multipart_form_request_fails_if_map_is_not_valid_json 1'] = [ - b"Request 'map' multipart field is not a valid JSON" -] - -snapshots['test_multipart_form_request_fails_if_operations_is_not_valid_json 1'] = [ - b"Request 'operations' multipart field is not a valid JSON" -] diff --git a/tests/wsgi/test_explorer.py b/tests/wsgi/test_explorer.py index ccc02db3a..b99709c1b 100644 --- a/tests/wsgi/test_explorer.py +++ b/tests/wsgi/test_explorer.py @@ -17,7 +17,7 @@ def test_default_explorer_html_is_served_on_get_request( start_response.assert_called_once_with( HTTP_STATUS_200_OK, playground_response_headers ) - snapshot.assert_match(response) + assert snapshot == response def test_apollo_html_is_served_on_get_request( @@ -29,7 +29,7 @@ def test_apollo_html_is_served_on_get_request( start_response.assert_called_once_with( HTTP_STATUS_200_OK, playground_response_headers ) - snapshot.assert_match(response) + assert snapshot == response def test_graphiql_html_is_served_on_get_request( @@ -41,7 +41,7 @@ def test_graphiql_html_is_served_on_get_request( start_response.assert_called_once_with( HTTP_STATUS_200_OK, playground_response_headers ) - snapshot.assert_match(response) + assert snapshot == response def test_playground_html_is_served_on_get_request( @@ -53,7 +53,7 @@ def test_playground_html_is_served_on_get_request( start_response.assert_called_once_with( HTTP_STATUS_200_OK, playground_response_headers ) - snapshot.assert_match(response) + assert snapshot == response def test_405_bad_method_is_served_on_get_request_for_disabled_explorer( @@ -70,4 +70,4 @@ def test_405_bad_method_is_served_on_get_request_for_disabled_explorer( ("Allow", "OPTIONS, POST, GET"), ], ) - snapshot.assert_match(response) + assert snapshot == response diff --git a/tests/wsgi/test_query_execution.py b/tests/wsgi/test_query_execution.py index 1ef5ccf84..b44bcc714 100644 --- a/tests/wsgi/test_query_execution.py +++ b/tests/wsgi/test_query_execution.py @@ -184,7 +184,7 @@ def test_query_is_executed_for_multipart_form_request_with_file( request = create_multipart_request(data) result = middleware(request, start_response) start_response.assert_called_once_with(HTTP_STATUS_200_OK, graphql_response_headers) - snapshot.assert_match(result) + assert snapshot == result class CustomExtension(Extension): diff --git a/tests/wsgi/test_request_data_reading.py b/tests/wsgi/test_request_data_reading.py index 02d43c7e2..7332693cb 100644 --- a/tests/wsgi/test_request_data_reading.py +++ b/tests/wsgi/test_request_data_reading.py @@ -20,7 +20,7 @@ def test_attempt_parse_request_missing_content_type_raises_bad_request_error( start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_parse_non_json_request_raises_bad_request_error( @@ -35,7 +35,7 @@ def test_attempt_parse_non_json_request_raises_bad_request_error( start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_get_content_length_from_missing_header_raises_bad_request_error( @@ -51,7 +51,7 @@ def test_attempt_get_content_length_from_missing_header_raises_bad_request_error start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_get_content_length_from_malformed_header_raises_bad_request_error( @@ -66,7 +66,7 @@ def test_attempt_get_content_length_from_malformed_header_raises_bad_request_err start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_get_request_body_from_missing_wsgi_input_raises_bad_request_error( @@ -82,7 +82,7 @@ def test_attempt_get_request_body_from_missing_wsgi_input_raises_bad_request_err start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_get_request_body_from_empty_wsgi_input_raises_bad_request_error( @@ -98,7 +98,7 @@ def test_attempt_get_request_body_from_empty_wsgi_input_raises_bad_request_error start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_parse_non_json_request_body_raises_bad_request_error( @@ -113,7 +113,7 @@ def test_attempt_parse_non_json_request_body_raises_bad_request_error( start_response.assert_called_once_with( HttpBadRequestError.status, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_attempt_parse_json_scalar_request_raises_graphql_bad_request_error( @@ -174,7 +174,7 @@ def test_multipart_form_request_fails_if_operations_is_not_valid_json( start_response.assert_called_once_with( HTTP_STATUS_400_BAD_REQUEST, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result def test_multipart_form_request_fails_if_map_is_not_valid_json( @@ -205,4 +205,4 @@ def test_multipart_form_request_fails_if_map_is_not_valid_json( start_response.assert_called_once_with( HTTP_STATUS_400_BAD_REQUEST, error_response_headers ) - snapshot.assert_match(result) + assert snapshot == result diff --git a/tests_integrations/fastapi/requirements.txt b/tests_integrations/fastapi/requirements.txt index 3d1860d3d..2c3dc6a24 100644 --- a/tests_integrations/fastapi/requirements.txt +++ b/tests_integrations/fastapi/requirements.txt @@ -1,20 +1,29 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --output-file=requirements.txt requirements.in # -anyio==3.6.2 - # via starlette -fastapi==0.89.1 +annotated-types==0.6.0 + # via pydantic +anyio==3.7.1 + # via + # fastapi + # starlette +fastapi==0.104.1 # via -r requirements.in idna==3.4 # via anyio -pydantic==1.10.4 +pydantic==2.4.2 # via fastapi +pydantic-core==2.10.1 + # via pydantic sniffio==1.3.0 # via anyio -starlette==0.22.0 +starlette==0.27.0 # via fastapi -typing-extensions==4.4.0 - # via pydantic +typing-extensions==4.8.0 + # via + # fastapi + # pydantic + # pydantic-core diff --git a/tests_integrations/flask/requirements.txt b/tests_integrations/flask/requirements.txt index 22657fb1b..d3383bcb3 100644 --- a/tests_integrations/flask/requirements.txt +++ b/tests_integrations/flask/requirements.txt @@ -4,15 +4,17 @@ # # pip-compile --output-file=requirements.txt requirements.in # -click==8.1.3 +blinker==1.7.0 # via flask -flask==2.2.5 +click==8.1.7 + # via flask +flask==3.0.0 # via -r requirements.in itsdangerous==2.1.2 # via flask jinja2==3.1.2 # via flask -markupsafe==2.1.2 +markupsafe==2.1.3 # via # jinja2 # werkzeug diff --git a/tests_integrations/starlette/requirements.txt b/tests_integrations/starlette/requirements.txt index fbf8b8822..3ad9ff560 100644 --- a/tests_integrations/starlette/requirements.txt +++ b/tests_integrations/starlette/requirements.txt @@ -4,11 +4,11 @@ # # pip-compile --output-file=requirements.txt requirements.in # -anyio==3.6.2 +anyio==4.0.0 # via starlette idna==3.4 # via anyio sniffio==1.3.0 # via anyio -starlette==0.27.0 +starlette==0.32.0.post1 # via -r requirements.in