#NEWLINE# def test_unit_spec_changes_do_not_boomerang( monkeypatch ) : #NEWLINE# #INDENT# application = Application ( ) #NEWLINE# with ManagedServerLoop ( application ) as server : #NEWLINE# #INDENT# doc = document . Document ( ) #NEWLINE# client_root = UnitsSpecModel ( ) #NEWLINE# doc . add_root ( client_root ) #NEWLINE# client_session = push_session ( doc , session_id = 'test_unit_spec_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 . distance == 42 ) #NEWLINE# assert ( server_root . angle == 0 ) #NEWLINE# def change_to( new_distance , new_angle ) : #NEWLINE# #INDENT# got_angry = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# got_angry [ 'result' ] = None #NEWLINE# def get_angry( message ) : #NEWLINE# #INDENT# got_angry [ 'result' ] = message #NEWLINE# #UNINDENT# monkeypatch . setattr ( client_session , '_handle_patch' , get_angry ) #NEWLINE# server_previous_distance = server_root . distance #NEWLINE# server_previous_angle = server_root . angle #NEWLINE# client_root . distance = new_distance #NEWLINE# client_root . angle = new_angle #NEWLINE# def server_change_made( ) : #NEWLINE# #INDENT# return ( ( server_root . distance != server_previous_distance ) and ( server_root . angle != server_previous_angle ) ) #NEWLINE# #UNINDENT# client_session . _connection . _loop_until ( server_change_made ) #NEWLINE# client_session . force_roundtrip ( ) #NEWLINE# assert ( got_angry [ 'result' ] is None ) #NEWLINE# #UNINDENT# change_to ( 57 , 1 ) #NEWLINE# change_to ( { #NEWLINE# #INDENT# 'value' : 58 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'value' : 2 , #NEWLINE# #UNINDENT# } ) #NEWLINE# change_to ( { #NEWLINE# #INDENT# 'field' : 'foo' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'field' : 'bar' , #NEWLINE# #UNINDENT# } ) #NEWLINE# change_to ( { #NEWLINE# #INDENT# 'value' : 59 , #NEWLINE# 'units' : 'screen' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'value' : 30 , #NEWLINE# 'units' : 'deg' , #NEWLINE# #UNINDENT# } ) #NEWLINE# client_session . close ( ) #NEWLINE# client_session . loop_until_closed ( ) #NEWLINE# assert ( not client_session . connected ) #NEWLINE# server . unlisten ( )