@@ -112,7 +112,8 @@ def deeper(self):
112112
113113 schema = GraphQLSchema (query = DataType )
114114
115- result = execute (schema , ast , Data (), operation_name = 'Example' , variable_values = {'size' : 100 })
115+ result = execute (schema , ast , Data (),
116+ operation_name = 'Example' , variable_values = {'size' : 100 })
116117 assert not result .errors
117118 assert result .data == expected
118119
@@ -178,7 +179,8 @@ def resolver(root_value, *_):
178179 'a' : GraphQLField (GraphQLString , resolver = resolver )
179180 })
180181
181- result = execute (GraphQLSchema (Type ), ast , Data (), operation_name = 'Example' )
182+ result = execute (GraphQLSchema (Type ), ast ,
183+ Data (), operation_name = 'Example' )
182184 assert not result .errors
183185 assert resolver .got_here
184186
@@ -209,7 +211,8 @@ def resolver(source, info, numArg, stringArg):
209211 resolver = resolver ),
210212 })
211213
212- result = execute (GraphQLSchema (Type ), doc_ast , None , operation_name = 'Example' )
214+ result = execute (GraphQLSchema (Type ), doc_ast ,
215+ None , operation_name = 'Example' )
213216 assert not result .errors
214217 assert resolver .got_here
215218
@@ -282,7 +285,8 @@ class Data(object):
282285 Type = GraphQLObjectType ('Type' , {
283286 'a' : GraphQLField (GraphQLString )
284287 })
285- result = execute (GraphQLSchema (Type ), ast , Data (), operation_name = 'OtherExample' )
288+ result = execute (GraphQLSchema (Type ), ast , Data (),
289+ operation_name = 'OtherExample' )
286290 assert not result .errors
287291 assert result .data == {'second' : 'b' }
288292
@@ -313,7 +317,8 @@ class Data(object):
313317 'a' : GraphQLField (GraphQLString )
314318 })
315319 with raises (GraphQLError ) as excinfo :
316- execute (GraphQLSchema (Type ), ast , Data (), operation_name = "UnknownExample" )
320+ execute (GraphQLSchema (Type ), ast , Data (),
321+ operation_name = "UnknownExample" )
317322 assert 'Unknown operation named "UnknownExample".' == str (excinfo .value )
318323
319324
@@ -329,7 +334,8 @@ class Data(object):
329334 })
330335 with raises (GraphQLError ) as excinfo :
331336 execute (GraphQLSchema (Type ), ast , Data ())
332- assert 'Must provide operation name if query contains multiple operations.' == str (excinfo .value )
337+ assert 'Must provide operation name if query contains multiple operations.' == str (
338+ excinfo .value )
333339
334340
335341def test_uses_the_query_schema_for_queries ():
@@ -374,6 +380,7 @@ class Data(object):
374380
375381
376382def test_uses_the_subscription_schema_for_subscriptions ():
383+ from rx import Observable
377384 doc = 'query Q { a } subscription S { a }'
378385
379386 class Data (object ):
@@ -385,9 +392,14 @@ class Data(object):
385392 'a' : GraphQLField (GraphQLString )
386393 })
387394 S = GraphQLObjectType ('S' , {
388- 'a' : GraphQLField (GraphQLString )
395+ 'a' : GraphQLField (GraphQLString , resolver = lambda root , info : Observable . from_ ([ 'b' ]) )
389396 })
390- result = execute (GraphQLSchema (Q , subscription = S ), ast , Data (), operation_name = 'S' )
397+ result = execute (GraphQLSchema (Q , subscription = S ),
398+ ast , Data (), operation_name = 'S' )
399+ assert isinstance (result , Observable )
400+ l = []
401+ result .subscribe (l .append )
402+ result = l [0 ]
391403 assert not result .errors
392404 assert result .data == {'a' : 'b' }
393405
@@ -437,7 +449,8 @@ def test_does_not_include_arguments_that_were_not_set():
437449 {
438450 'field' : GraphQLField (
439451 GraphQLString ,
440- resolver = lambda source , info , ** args : args and json .dumps (args , sort_keys = True , separators = (',' , ':' )),
452+ resolver = lambda source , info , ** args : args and json .dumps (
453+ args , sort_keys = True , separators = (',' , ':' )),
441454 args = {
442455 'a' : GraphQLArgument (GraphQLBoolean ),
443456 'b' : GraphQLArgument (GraphQLBoolean ),
@@ -501,7 +514,8 @@ def __init__(self, value):
501514 ]
502515 }
503516
504- assert 'Expected value of type "SpecialType" but got: NotSpecial.' in [str (e ) for e in result .errors ]
517+ assert 'Expected value of type "SpecialType" but got: NotSpecial.' in [
518+ str (e ) for e in result .errors ]
505519
506520
507521def test_fails_to_execute_a_query_containing_a_type_definition ():
@@ -547,7 +561,8 @@ def resolver(*_):
547561 )
548562
549563 execute (schema , query )
550- logger .exception .assert_called_with ("An error occurred while resolving field Query.foo" )
564+ logger .exception .assert_called_with (
565+ "An error occurred while resolving field Query.foo" )
551566
552567
553568def test_middleware ():
@@ -576,7 +591,8 @@ def reversed_middleware(next, *args, **kwargs):
576591 return p .then (lambda x : x [::- 1 ])
577592
578593 middlewares = MiddlewareManager (reversed_middleware )
579- result = execute (GraphQLSchema (Type ), doc_ast , Data (), middleware = middlewares )
594+ result = execute (GraphQLSchema (Type ), doc_ast ,
595+ Data (), middleware = middlewares )
580596 assert result .data == {'ok' : 'ko' , 'not_ok' : 'ko_ton' }
581597
582598
@@ -607,7 +623,8 @@ def resolve(self, next, *args, **kwargs):
607623 return p .then (lambda x : x [::- 1 ])
608624
609625 middlewares = MiddlewareManager (MyMiddleware ())
610- result = execute (GraphQLSchema (Type ), doc_ast , Data (), middleware = middlewares )
626+ result = execute (GraphQLSchema (Type ), doc_ast ,
627+ Data (), middleware = middlewares )
611628 assert result .data == {'ok' : 'ko' , 'not_ok' : 'ko_ton' }
612629
613630
@@ -640,9 +657,14 @@ class MyEmptyMiddleware(object):
640657 def resolve (self , next , * args , ** kwargs ):
641658 return next (* args , ** kwargs )
642659
643- middlewares_with_promise = MiddlewareManager (MyPromiseMiddleware (), wrap_in_promise = False )
644- middlewares_without_promise = MiddlewareManager (MyEmptyMiddleware (), wrap_in_promise = False )
645-
646- result1 = execute (GraphQLSchema (Type ), doc_ast , Data (), middleware = middlewares_with_promise )
647- result2 = execute (GraphQLSchema (Type ), doc_ast , Data (), middleware = middlewares_without_promise )
648- assert result1 .data == result2 .data and result1 .data == {'ok' : 'ok' , 'not_ok' : 'not_ok' }
660+ middlewares_with_promise = MiddlewareManager (
661+ MyPromiseMiddleware (), wrap_in_promise = False )
662+ middlewares_without_promise = MiddlewareManager (
663+ MyEmptyMiddleware (), wrap_in_promise = False )
664+
665+ result1 = execute (GraphQLSchema (Type ), doc_ast , Data (),
666+ middleware = middlewares_with_promise )
667+ result2 = execute (GraphQLSchema (Type ), doc_ast , Data (),
668+ middleware = middlewares_without_promise )
669+ assert result1 .data == result2 .data and result1 .data == {
670+ 'ok' : 'ok' , 'not_ok' : 'not_ok' }
0 commit comments