1
+ import pytest
1
2
from promise import Promise
2
3
from promise .dataloader import DataLoader
3
4
4
5
from graphql import GraphQLObjectType , GraphQLField , GraphQLID , GraphQLArgument , GraphQLNonNull , GraphQLSchema , parse , execute
6
+ from graphql .execution .executors .sync import SyncExecutor
7
+ from graphql .execution .executors .thread import ThreadExecutor
5
8
6
9
7
- def test_batches_correctly ():
10
+ @pytest .mark .parametrize ("executor" , [
11
+ SyncExecutor (),
12
+ ThreadExecutor (),
13
+ ])
14
+ def test_batches_correctly (executor ):
8
15
9
16
Business = GraphQLObjectType ('Business' , lambda : {
10
17
'id' : GraphQLField (GraphQLID , resolver = lambda root , args , context , info : root ),
@@ -46,7 +53,7 @@ class Context(object):
46
53
business_data_loader = BusinessDataLoader ()
47
54
48
55
49
- result = execute (schema , doc_ast , None , context_value = Context ())
56
+ result = execute (schema , doc_ast , None , context_value = Context (), executor = executor )
50
57
assert not result .errors
51
58
assert result .data == {
52
59
'business1' : {
@@ -59,7 +66,11 @@ class Context(object):
59
66
assert load_calls == [['1' ,'2' ]]
60
67
61
68
62
- def test_batches_multiple_together ():
69
+ @pytest .mark .parametrize ("executor" , [
70
+ SyncExecutor (),
71
+ ThreadExecutor (),
72
+ ])
73
+ def test_batches_multiple_together (executor ):
63
74
64
75
Location = GraphQLObjectType ('Location' , lambda : {
65
76
'id' : GraphQLField (GraphQLID , resolver = lambda root , args , context , info : root ),
@@ -122,7 +133,7 @@ class Context(object):
122
133
location_data_loader = LocationDataLoader ()
123
134
124
135
125
- result = execute (schema , doc_ast , None , context_value = Context ())
136
+ result = execute (schema , doc_ast , None , context_value = Context (), executor = executor )
126
137
assert not result .errors
127
138
assert result .data == {
128
139
'business1' : {
0 commit comments