#NEWLINE# def test_executor_can_enforce_strict_ordering( ) : #NEWLINE# #INDENT# Type = GraphQLObjectType ( 'Type' , ( lambda : { #NEWLINE# #INDENT# 'a' : GraphQLField ( GraphQLString , resolver = ( lambda * _ : 'Apple' ) ) , #NEWLINE# 'b' : GraphQLField ( GraphQLString , resolver = ( lambda * _ : 'Banana' ) ) , #NEWLINE# 'c' : GraphQLField ( GraphQLString , resolver = ( lambda * _ : 'Cherry' ) ) , #NEWLINE# 'deep' : GraphQLField ( Type , resolver = ( lambda * _ : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# schema = GraphQLSchema ( query = Type ) #NEWLINE# executor = Executor ( execution_middlewares = [ SynchronousExecutionMiddleware ] , map_type = OrderedDict ) #NEWLINE# query = '{ a b c aa: c cc: c bb: b aaz: a bbz: b deep { b a c deeper: deep { c a b } } ccz: c zzz: c aaa: a }' #NEWLINE# def check_result( result ) : #NEWLINE# #INDENT# assert ( not result . errors ) #NEWLINE# data = result . data #NEWLINE# assert isinstance ( data , OrderedDict ) #NEWLINE# assert ( list ( data . keys ( ) ) == [ 'a' , 'b' , 'c' , 'aa' , 'cc' , 'bb' , 'aaz' , 'bbz' , 'deep' , 'ccz' , 'zzz' , 'aaa' ] ) #NEWLINE# deep = data [ 'deep' ] #NEWLINE# assert isinstance ( deep , OrderedDict ) #NEWLINE# assert ( list ( deep . keys ( ) ) == [ 'b' , 'a' , 'c' , 'deeper' ] ) #NEWLINE# deeper = deep [ 'deeper' ] #NEWLINE# assert isinstance ( deeper , OrderedDict ) #NEWLINE# assert ( list ( deeper . keys ( ) ) == [ 'c' , 'a' , 'b' ] ) #NEWLINE# #UNINDENT# check_result ( executor . execute ( schema , query ) ) #NEWLINE# check_result ( executor . execute ( schema , executor , execute_serially = True ) )