#NEWLINE# def test_client_changes_go_to_server( self ) : #NEWLINE# #INDENT# application = Application ( ) #NEWLINE# with ManagedServerLoop ( application ) as server : #NEWLINE# #INDENT# doc = document . Document ( ) #NEWLINE# client_root = SomeModelInTestClientServer ( foo = 42 ) #NEWLINE# client_session = push_session ( doc , session_id = 'test_client_changes_go_to_server' , url = url ( server_root ) , io_loop = server . io_loop ) #NEWLINE# server_session = server . get_session ( '/' , client_session . id ) #NEWLINE# assert ( len ( server_session . document . roots ) == 0 ) #NEWLINE# doc . add_root ( client_root ) #NEWLINE# client_session . force_roundtrip ( ) #NEWLINE# assert ( len ( server_session . document . roots ) == 1 ) #NEWLINE# server_root = next ( iter ( server_session . document . roots ) ) #NEWLINE# assert ( client_root . foo == 42 ) #NEWLINE# assert ( server_root . foo == 42 ) #NEWLINE# assert ( server_session . document . title == document . DEFAULT_TITLE ) #NEWLINE# doc . title = 'Client Title' #NEWLINE# client_session . force_roundtrip ( ) #NEWLINE# assert ( server_session . document . title == 'Client Title' ) #NEWLINE# client_root . foo = 57 #NEWLINE# def server_change_made( ) : #NEWLINE# #INDENT# return ( server_root . foo == 57 ) #NEWLINE# #UNINDENT# client_session . _connection . _loop_until ( server_change_made ) #NEWLINE# assert ( server_root . foo == 57 ) #NEWLINE# doc . remove_root ( client_root ) #NEWLINE# client_session . force_roundtrip ( ) #NEWLINE# assert ( len ( server_session . document . roots ) == 0 ) #NEWLINE# client_session . close ( ) #NEWLINE# client_session . loop_until_closed ( ) #NEWLINE# assert ( not client_session . connected )