#NEWLINE# def test_server_changes_do_not_boomerang( monkeypatch ) : #NEWLINE# #INDENT# application = Application ( ) #NEWLINE# with ManagedServerLoop ( application ) as server : #NEWLINE# #INDENT# doc = document . Document ( ) #NEWLINE# client_root = SomeModelInTestClientServer ( foo = 42 ) #NEWLINE# doc . add_root ( client_root ) #NEWLINE# client_session = push_session ( doc , session_id = 'test_server_changes_do_not_boomerang' , url = url ( server ) , io_loop = server . io_loop ) #NEWLINE# server_session = server . get_session ( '/' , client_session . id ) #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# got_angry = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# got_angry [ 'result' ] = None #NEWLINE# def get_angry( message , connection ) : #NEWLINE# #INDENT# got_angry [ 'result' ] = message #NEWLINE# #UNINDENT# monkeypatch . setattr ( server_session , '_handle_patch' , get_angry ) #NEWLINE# def do_set_foo_property( ) : #NEWLINE# #INDENT# server_root . foo = 57 #NEWLINE# #UNINDENT# server_session . with_document_locked ( do_set_foo_property ) #NEWLINE# def client_change_made( ) : #NEWLINE# #INDENT# return ( client_root . foo == 57 ) #NEWLINE# #UNINDENT# client_session . _connection . _loop_until ( client_change_made ) #NEWLINE# assert ( doc . foo == 57 ) #NEWLINE# client_session . force_roundtrip ( ) #NEWLINE# assert ( got_angry [ 'result' ] is None ) #NEWLINE# client_session . close ( ) #NEWLINE# client_session . loop_until_closed ( ) #NEWLINE# assert ( not client_session . connected )