#NEWLINE# def test_namespace_manager( self ) : #NEWLINE# #INDENT# router_id = _uuid ( ) #NEWLINE# router_id_to_delete = _uuid ( ) #NEWLINE# to_keep = set ( ) #NEWLINE# to_delete = set ( ) #NEWLINE# to_retrieve = set ( ) #NEWLINE# to_keep . add ( self . _create_namespace ( router_id , namespaces . RouterNamespace ) ) #NEWLINE# to_keep . add ( self . _create_namespace ( id_to_keep , dvr_snat_ns . SnatNamespace ) ) #NEWLINE# to_delete . add ( self . _create_namespace ( router_id_to_delete , dvr_snat_ns . SnatNamespace ) ) #NEWLINE# to_retrieve = ( to_keep | to_delete ) #NEWLINE# with mock . patch . object ( namespace_manager . NamespaceManager , 'list_all' , return_value = to_retrieve ) : #NEWLINE# #INDENT# with self . namespace_manager as ns_manager : #NEWLINE# #INDENT# for ns_name in to_keep : #NEWLINE# #INDENT# id_to_keep = ns_manager . get_prefix_and_id ( ns_name ) [ 1 ] #NEWLINE# ns_manager . keep_router ( id_to_keep ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for ns_name in to_keep : #NEWLINE# #INDENT# self . assertTrue ( self . _namespace_exists ( ns_name ) ) #NEWLINE# #UNINDENT# for ns_name in to_delete : #NEWLINE# #INDENT# self . metadata_driver_mock . destroy_monitored_metadata_proxy . assert_called_once_with ( mock . ANY , router_id_to_delete , self . agent_conf ) #NEWLINE# self . assertFalse ( self . _namespace_exists ( ns_name ) )