#NEWLINE# def test_eager_load_accept_queries( self ) : #NEWLINE# #INDENT# model = OrmBuilderTestModelCloseRelated ( ) #NEWLINE# flexmock ( Builder ) #NEWLINE# builder = Builder ( flexmock ( QueryBuilder ( None , None , None ) ) ) #NEWLINE# nop1 = OrmBuilderTestModelFarRelatedStub . where ( 'id' , 5 ) #NEWLINE# builder . set_eager_loads ( { #NEWLINE# #INDENT# 'foo' : nop1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# relation = flexmock ( ) #NEWLINE# relation . should_receive ( 'add_eager_constraints' ) . once ( ) . with_args ( [ 'models' ] ) #NEWLINE# relation . should_receive ( 'init_relation' ) . once ( ) . with_args ( [ 'models' ] , 'foo' ) . and_return ( [ 'models' ] ) #NEWLINE# relation . should_receive ( 'get_eager' ) . once ( ) . and_return ( [ 'results' ] ) #NEWLINE# relation . should_receive ( 'match' ) . once ( ) . with_args ( [ 'models' ] , [ 'results' ] , 'foo' ) . and_return ( [ 'foo' ] ) #NEWLINE# builder . should_receive ( 'get_relation' ) . once ( ) . with_args ( 'foo' ) . and_return ( relation ) #NEWLINE# relation . should_receive ( 'merge_query' ) . with_args ( nop1 ) . and_return ( relation ) #NEWLINE# results = builder . eager_load_relations ( [ 'models' ] ) #NEWLINE# self . assertEqual ( [ 'foo' ] , results )