#NEWLINE# def _test_plug( self , additional_expectation = None , bridge = None , namespace = None ) : #NEWLINE# #INDENT# additional_expectation = ( additional_expectation or [ ] ) #NEWLINE# if ( not bridge ) : #NEWLINE# #INDENT# bridge = 'br-int' #NEWLINE# #UNINDENT# def device_exists( dev , namespace = None ) : #NEWLINE# #INDENT# return ( dev == bridge ) #NEWLINE# #UNINDENT# with mock . patch . object ( ovs_lib . OVSBridge , 'replace_port' ) as replace : #NEWLINE# #INDENT# ovs = interface . OVSInterfaceDriver ( self . conf ) #NEWLINE# self . device_exists . side_effect = device_exists #NEWLINE# ovs . plug ( '01234567-1234-1234-99' , 'port-1234' , 'tap0' , 'aa:bb:cc:dd:ee:ff' , bridge = bridge , namespace = namespace ) #NEWLINE# replace . assert_called_once_with ( 'tap0' , ( 'type' , 'internal' ) , ( '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# expected = [ mock . call ( ) , mock . call ( ) . device ( 'tap0' ) , mock . call ( ) . device ( ) . link . set_address ( 'aa:bb:cc:dd:ee:ff' ) ] #NEWLINE# expected . extend ( additional_expectation ) #NEWLINE# if namespace : #NEWLINE# #INDENT# expected . extend ( [ mock . call ( ) . ensure_namespace ( namespace ) , mock . call ( ) . ensure_namespace ( ) . add_device_to_namespace ( mock . ANY ) ] ) #NEWLINE# #UNINDENT# expected . extend ( [ mock . call ( ) . device ( ) . link . set_up ( ) ] ) #NEWLINE# self . ip . assert_has_calls ( expected )