#NEWLINE# def test_update_publicized_collection_status_in_search( self ) : #NEWLINE# #INDENT# def mock_get_doc( doc_id , index ) : #NEWLINE# #INDENT# self . assertEqual ( index , collection_services . SEARCH_INDEX_COLLECTIONS ) #NEWLINE# self . assertEqual ( doc_id , self . COLLECTION_ID ) #NEWLINE# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# def mock_add_docs( docs , index ) : #NEWLINE# #INDENT# self . assertEqual ( index , collection_services . SEARCH_INDEX_COLLECTIONS ) #NEWLINE# self . assertEqual ( docs , [ { #NEWLINE# #INDENT# 'is' : 'featured' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# #UNINDENT# def mock_get_rights( unused_collection_id ) : #NEWLINE# #INDENT# return rights_manager . ActivityRights ( self . COLLECTION_ID , [ self . owner_id ] , [ self . editor_id ] , [ self . viewer_id ] , status = rights_manager . ACTIVITY_STATUS_PUBLICIZED ) #NEWLINE# #UNINDENT# get_doc_counter = test_utils . CallCounter ( mock_get_doc ) #NEWLINE# add_docs_counter = test_utils . CallCounter ( mock_get_doc ) #NEWLINE# get_doc_swap = self . swap ( search_services , 'get_document_from_index' , get_doc_counter ) #NEWLINE# add_docs_swap = self . swap ( search_services , 'add_documents_to_index' , add_docs_counter ) #NEWLINE# get_rights_swap = self . swap ( rights_manager , 'get_collection_rights' , mock_get_rights ) #NEWLINE# with get_doc_swap , add_docs_swap , get_rights_swap : #NEWLINE# #INDENT# collection_services . update_collection_status_in_search ( self . COLLECTION_ID ) #NEWLINE# #UNINDENT# self . assertEqual ( get_doc_counter . times_called , 1 ) #NEWLINE# self . assertEqual ( add_docs_counter . times_called , 1 )