#NEWLINE# def test_garbage_collect_namespace_existing_not_empty( self ) : #NEWLINE# #INDENT# lo_device = mock . Mock ( ) #NEWLINE# lo_device . name = 'lo' #NEWLINE# tap_device = mock . Mock ( ) #NEWLINE# tap_device . name = 'tap1' #NEWLINE# with mock . patch . object ( ip_lib , 'IpNetnsCommand' ) as ip_ns_cmd_cls : #NEWLINE# #INDENT# ip_ns_cmd_cls . return_value . exists . return_value = True #NEWLINE# ip = ip_lib . IPWrapper ( namespace = 'ns' ) #NEWLINE# with mock . patch . object ( ip , 'namespace_is_empty' ) as mock_is_empty : #NEWLINE# #INDENT# mock_is_empty . return_value = False #NEWLINE# self . assertFalse ( ip . garbage_collect_namespace ( ) ) #NEWLINE# mock_is_empty . assert_called_once_with ( ) #NEWLINE# expected = [ mock . call ( ip ) , mock . call ( ) . exists ( 'ns' ) ] #NEWLINE# self . assertEqual ( ip_ns_cmd_cls . mock_calls , expected ) #NEWLINE# self . assertNotIn ( mock . call ( ) . delete ( 'ns' ) , self . mock_calls )