#NEWLINE# def test_pull_document( self ) : #NEWLINE# #INDENT# application = Application ( ) #NEWLINE# def add_roots( doc ) : #NEWLINE# #INDENT# doc . add_root ( AnotherModelInTestClientServer ( bar = 43 ) ) #NEWLINE# doc . add_root ( SomeModelInTestClientServer ( foo = 42 ) ) #NEWLINE# #UNINDENT# handler = FunctionHandler ( add_roots ) #NEWLINE# application . add ( handler ) #NEWLINE# with ManagedServerLoop ( application ) as server : #NEWLINE# #INDENT# client_session = pull_session ( session_id = 'test_pull_document' , url = url ( server ) , io_loop = server . io_loop ) #NEWLINE# assert ( len ( client_session . document . roots ) == 2 ) #NEWLINE# server_session = server . get_session ( '/' , client_session . id ) #NEWLINE# assert ( len ( server_session . document . roots ) == 2 ) #NEWLINE# results = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for r in server_session . document . roots : #NEWLINE# #INDENT# if hasattr ( r , 'foo' ) : #NEWLINE# #INDENT# results [ 'foo' ] = r . foo #NEWLINE# #UNINDENT# if hasattr ( r , 'bar' ) : #NEWLINE# #INDENT# results [ 'bar' ] = r . bar #NEWLINE# #UNINDENT# #UNINDENT# assert ( handler [ 'foo' ] == 42 ) #NEWLINE# assert ( results [ 'bar' ] == 43 ) #NEWLINE# client_session . close ( ) #NEWLINE# client_session . loop_until_closed ( ) #NEWLINE# assert ( not client_session . connected )