#NEWLINE# def _test_plug( self , devname = None , bridge = None , namespace = None , prefix = None , mtu = None ) : #NEWLINE# #INDENT# if ( not devname ) : #NEWLINE# #INDENT# devname = 'ns-0' #NEWLINE# #UNINDENT# if ( not bridge ) : #NEWLINE# #INDENT# bridge = 'br-int' #NEWLINE# #UNINDENT# def device_exists( dev , namespace = None ) : #NEWLINE# #INDENT# return ( dev == bridge ) #NEWLINE# #UNINDENT# ovs = interface . OVSInterfaceDriver ( self . conf ) #NEWLINE# self . device_exists . side_effect = device_exists #NEWLINE# root_dev = mock . Mock ( ) #NEWLINE# ns_dev = mock . Mock ( ) #NEWLINE# self . ip ( ) . add_veth = mock . Mock ( return_value = ( root_dev , ns_dev ) ) #NEWLINE# expected = [ mock . call ( ) , mock . call ( ) . add_veth ( 'tap0' , devname , namespace2 = namespace ) ] #NEWLINE# with mock . patch . object ( ovs_lib . OVSBridge , 'replace_port' ) as replace : #NEWLINE# #INDENT# ovs . plug ( '01234567-1234-1234-99' , 'port-1234' , devname , 'aa:bb:cc:dd:ee:ff' , bridge = bridge , namespace = namespace , prefix = prefix ) #NEWLINE# replace . assert_called_once_with ( 'tap0' , ( 'external_ids' , { #NEWLINE# #INDENT# 'iface-id' : 'port-1234' , #NEWLINE# 'iface-status' : 'active' , #NEWLINE# 'attached-mac' : 'aa:bb:cc:dd:ee:ff' , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# ns_dev . assert_has_calls ( [ mock . call . link . set_address ( 'aa:bb:cc:dd:ee:ff' ) ] ) #NEWLINE# if mtu : #NEWLINE# #INDENT# ns_dev . assert_has_calls ( [ mock . call . link . set_mtu ( mtu ) ] ) #NEWLINE# root_dev . assert_has_calls ( [ mock . call . link . set_mtu ( mtu ) ] ) #NEWLINE# #UNINDENT# self . ip . assert_has_calls ( self ) #NEWLINE# root_dev . assert_has_calls ( [ mock . call . link . set_up ( ) ] ) #NEWLINE# ns_dev . assert_has_calls ( [ mock . call . link . set_up ( ) ] )