#NEWLINE# def test_index_collections_given_ids( self ) : #NEWLINE# #INDENT# all_collection_ids = [ 'id0' , 'id1' , 'id2' , 'id3' , 'id4' ] #NEWLINE# expected_collection_ids = all_collection_ids [ : ( - 1 ) ] #NEWLINE# all_collection_titles = [ 'title 0' , 'title 1' , 'title 2' , 'title 3' , 'title 4' ] #NEWLINE# expected_collection_titles = all_collection_titles [ : ( - 1 ) ] #NEWLINE# all_collection_categories = [ 'cat0' , 'cat1' , 'cat2' , 'cat3' , 'cat4' ] #NEWLINE# expected_collection_categories = all_collection_categories [ : ( - 1 ) ] #NEWLINE# def mock_add_documents_to_index( docs , index ) : #NEWLINE# #INDENT# self . assertEqual ( index , collection_services . SEARCH_INDEX_COLLECTIONS ) #NEWLINE# ids = [ doc [ 'id' ] for doc in docs ] #NEWLINE# titles = [ doc [ 'title' ] for doc in docs ] #NEWLINE# categories = [ doc [ 'category' ] for doc in docs ] #NEWLINE# self . assertEqual ( set ( ids ) , set ( expected_collection_ids ) ) #NEWLINE# self . assertEqual ( set ( titles ) , set ( expected_collection_titles ) ) #NEWLINE# self . assertEqual ( set ( categories ) , set ( expected_collection_categories ) ) #NEWLINE# return ids #NEWLINE# #UNINDENT# add_docs_counter = test_utils . CallCounter ( mock_add_documents_to_index ) #NEWLINE# add_docs_swap = self . swap ( search_services , 'add_documents_to_index' , add_docs_counter ) #NEWLINE# for ind in xrange ( 5 ) : #NEWLINE# #INDENT# self . save_new_valid_collection ( all_collection_ids [ ind ] , self . owner_id , all_collection_titles [ ind ] , category = all_collection_categories [ ind ] ) #NEWLINE# #UNINDENT# for ind in xrange ( 4 ) : #NEWLINE# #INDENT# rights_manager . publish_collection ( self . owner_id , expected_collection_ids [ ind ] ) #NEWLINE# #UNINDENT# with add_docs_swap : #NEWLINE# #INDENT# collection_services . index_collections_given_ids ( all_collection_ids ) #NEWLINE# #UNINDENT# self . assertEqual ( add_docs_counter . times_called , 1 )