#NEWLINE# def test_ensure_namespace( self ) : #NEWLINE# #INDENT# with mock . patch . object ( ip_lib , 'IPDevice' ) as ip_dev : #NEWLINE# #INDENT# ip = ip_lib . IPWrapper ( ) #NEWLINE# with mock . patch . object ( ip . netns , 'exists' ) as ns_exists : #NEWLINE# #INDENT# with mock . patch ( 'neutron.agent.common.utils.execute' ) : #NEWLINE# #INDENT# ns_exists . return_value = False #NEWLINE# ip . ensure_namespace ( 'ns' ) #NEWLINE# self . execute . assert_has_calls ( [ mock . call ( [ ] , 'netns' , ( 'add' , 'ns' ) , run_as_root = True , namespace = None , log_fail_as_error = True ) ] ) #NEWLINE# ip_dev . assert_has_calls ( [ mock . call ( 'lo' , namespace = 'ns' ) , mock . call ( ) . link . set_up ( ) ] )