#NEWLINE# def test_create_ports_bulk_emulated_plugin_failure( self ) : #NEWLINE# #INDENT# real_has_attr = hasattr #NEWLINE# def fakehasattr( item , attr ) : #NEWLINE# #INDENT# if attr . endswith ( '__native_bulk_support' ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return real_has_attr ( item , attr ) #NEWLINE# #UNINDENT# with mock . patch ( 'six.moves.hasattr' , new = fakehasattr ) : #NEWLINE# #INDENT# plugin_obj = manager . NeutronManager . get_plugin ( ) #NEWLINE# orig = plugin_obj . create_port #NEWLINE# with mock . patch . object ( plugin_obj , '_create_port_db' ) as patched_plugin : #NEWLINE# #INDENT# def side_effect( * args , **kwargs ) : #NEWLINE# #INDENT# return self . _fail_second_call ( patched_plugin , orig , * args , ** kwargs ) #NEWLINE# #UNINDENT# patched_plugin . side_effect = side_effect #NEWLINE# with self . network ( ) as net : #NEWLINE# #INDENT# res = self . _create_port_bulk ( self . fmt , 2 , net [ 'network' ] [ 'id' ] , 'test' , True ) #NEWLINE# self . _validate_behavior_on_bulk_failure ( res , 'ports' , wexc . HTTPInternalServerError . code )