11from typing import Optional
22
33import pytest
4+ from jinja2 import Environment
45from quart import Quart , Response , url_for
56from quart .typing import TestClientProtocol
67from werkzeug .datastructures import Headers
78
89from .app import create_app
910
1011
11- @pytest .fixture
12- def app () -> Quart :
13- # import app factory pattern
14- app = create_app (graphiql = True )
15-
16- # pushes an application context manually
17- # ctx = app.app_context()
18- # await ctx.push()
19- return app
20-
21-
22- @pytest .fixture
23- def client (app : Quart ) -> TestClientProtocol :
24- return app .test_client ()
25-
26-
2712@pytest .mark .asyncio
2813async def execute_client (
2914 app : Quart ,
@@ -39,6 +24,10 @@ async def execute_client(
3924
4025
4126@pytest .mark .asyncio
27+ @pytest .mark .parametrize (
28+ "app" ,
29+ [create_app (graphiql = True ), create_app (graphiql = True , jinja_env = Environment ())],
30+ )
4231async def test_graphiql_is_enabled (app : Quart , client : TestClientProtocol ):
4332 response = await execute_client (
4433 app , client , headers = Headers ({"Accept" : "text/html" }), externals = False
@@ -47,6 +36,10 @@ async def test_graphiql_is_enabled(app: Quart, client: TestClientProtocol):
4736
4837
4938@pytest .mark .asyncio
39+ @pytest .mark .parametrize (
40+ "app" ,
41+ [create_app (graphiql = True ), create_app (graphiql = True , jinja_env = Environment ())],
42+ )
5043async def test_graphiql_renders_pretty (app : Quart , client : TestClientProtocol ):
5144 response = await execute_client (
5245 app , client , headers = Headers ({"Accept" : "text/html" }), query = "{test}"
@@ -64,6 +57,10 @@ async def test_graphiql_renders_pretty(app: Quart, client: TestClientProtocol):
6457
6558
6659@pytest .mark .asyncio
60+ @pytest .mark .parametrize (
61+ "app" ,
62+ [create_app (graphiql = True ), create_app (graphiql = True , jinja_env = Environment ())],
63+ )
6764async def test_graphiql_default_title (app : Quart , client : TestClientProtocol ):
6865 response = await execute_client (
6966 app , client , headers = Headers ({"Accept" : "text/html" })
@@ -74,7 +71,13 @@ async def test_graphiql_default_title(app: Quart, client: TestClientProtocol):
7471
7572@pytest .mark .asyncio
7673@pytest .mark .parametrize (
77- "app" , [create_app (graphiql = True , graphiql_html_title = "Awesome" )]
74+ "app" ,
75+ [
76+ create_app (graphiql = True , graphiql_html_title = "Awesome" ),
77+ create_app (
78+ graphiql = True , graphiql_html_title = "Awesome" , jinja_env = Environment ()
79+ ),
80+ ],
7881)
7982async def test_graphiql_custom_title (app : Quart , client : TestClientProtocol ):
8083 response = await execute_client (
0 commit comments