#NEWLINE# def _test_update_port_binding( self , host , new_host = None ) : #NEWLINE# #INDENT# with mock . patch . object ( self . plugin , '_notify_port_updated' ) as notify_mock : #NEWLINE# #INDENT# host_arg = { #NEWLINE# #INDENT# portbindings . HOST_ID : host , #NEWLINE# #UNINDENT# } #NEWLINE# update_body = { #NEWLINE# #INDENT# 'name' : 'test_update' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( new_host is not None ) : #NEWLINE# #INDENT# update_body [ portbindings . HOST_ID ] = new_host #NEWLINE# #UNINDENT# with self . port ( name = 'name' , arg_list = ( portbindings . HOST_ID , ) , ** host_arg ) as port : #NEWLINE# #INDENT# neutron_context = context . get_admin_context ( ) #NEWLINE# updated_port = self . _update ( 'ports' , port [ 'port' ] [ 'id' ] , { #NEWLINE# #INDENT# 'port' : update_body , #NEWLINE# #UNINDENT# } , neutron_context = neutron_context ) #NEWLINE# port_data = updated_port [ 'port' ] #NEWLINE# if ( new_host is not None ) : #NEWLINE# #INDENT# self . assertEqual ( new_host , port_data [ portbindings . HOST_ID ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( host , port_data [ portbindings . HOST_ID ] ) #NEWLINE# #UNINDENT# if ( ( new_host is not None ) and ( new_host != host ) ) : #NEWLINE# #INDENT# notify_mock . assert_called_once_with ( mock . ANY ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertFalse ( notify_mock . called )