#NEWLINE# @ mock . patch . object ( neutron . NeutronDHCPApi , '_rollback_cleaning_ports' ) #NEWLINE# @ mock . patch . object ( client . Client , 'create_port' ) #NEWLINE# def test_create_cleaning_ports_fail( self , create_mock , rollback_mock ) : #NEWLINE# #INDENT# create_mock . side_effect = neutron_client_exc . ConnectionFailed #NEWLINE# api = dhcp_factory . DHCPFactory ( ) . provider #NEWLINE# with task_manager . acquire ( self . context , self . node . uuid ) as task : #NEWLINE# #INDENT# self . assertRaises ( exception . NodeCleaningFailure , api . create_cleaning_ports , task ) #NEWLINE# create_mock . assert_called_once_with ( { #NEWLINE# #INDENT# 'port' : { #NEWLINE# #INDENT# 'network_id' : '00000000-0000-0000-0000-000000000000' , #NEWLINE# 'admin_state_up' : True , #NEWLINE# 'mac_address' : self . ports [ 0 ] . address , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# rollback_mock . assert_called_once_with ( task )