Skip to content

Fix tests #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions graphql_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ def get_response(
if not params.query:
raise HttpQueryError(400, "Must provide query string.")

# Sanity check query
if not isinstance(params.query, str):
raise HttpQueryError(400, "Unexpected query type.")

schema_validation_errors = validate_schema(schema)
if schema_validation_errors:
return ExecutionResult(data=None, errors=schema_validation_errors)
Expand Down
28 changes: 12 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from re import search
from setuptools import setup, find_packages

install_requires = [
"graphql-core>=3.1.0,<4",
"typing-extensions>=3.7.4,<4"
]
install_requires = ["graphql-core>=3.1.0,<4", "typing-extensions>=3.7.4,<4"]

tests_requires = [
"pytest>=5.4,<5.5",
Expand All @@ -23,11 +20,11 @@
] + tests_requires

install_flask_requires = [
"flask>=0.7.0",
"flask>=0.7.0<1",
]

install_sanic_requires = [
"sanic>=20.3.0",
"sanic>=20.3.0,<21",
]

install_webob_requires = [
Expand All @@ -38,17 +35,16 @@
"aiohttp>=3.5.0,<4",
]

install_quart_requires = [
"quart>=0.6.15"
]
install_quart_requires = ["quart>=0.6.15,<1"]

install_all_requires = \
install_requires + \
install_flask_requires + \
install_sanic_requires + \
install_webob_requires + \
install_aiohttp_requires + \
install_quart_requires
install_all_requires = (
install_requires
+ install_flask_requires
+ install_sanic_requires
+ install_webob_requires
+ install_aiohttp_requires
+ install_quart_requires
)

with open("graphql_server/version.py") as version_file:
version = search('version = "(.*)"', version_file.read()).group(1)
Expand Down
3 changes: 3 additions & 0 deletions tests/sanic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from .schema import Schema


Sanic.test_mode = True


def create_app(path="/graphql", **kwargs):
app = Sanic(__name__)
app.debug = True
Expand Down
6 changes: 4 additions & 2 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,10 @@ def test_handles_errors_caused_by_a_lack_of_query():


def test_handles_errors_caused_by_invalid_query_type():
results, params = run_http_query(schema, "get", dict(query=42))
assert results == [(None, [{"message": "Must provide Source. Received: 42."}])]
with raises(HttpQueryError) as exc_info:
results, params = run_http_query(schema, "get", dict(query=42))

assert exc_info.value == HttpQueryError(400, "Unexpected query type.")


def test_handles_batch_correctly_if_is_disabled():
Expand Down