#NEWLINE# @ mock . patch ( 'simple_elasticsearch.mixins.ElasticsearchIndexMixin.index_add' ) #NEWLINE# @ mock . patch ( 'simple_elasticsearch.mixins.ElasticsearchIndexMixin.index_delete' ) #NEWLINE# def test__index_add_or_delete( self , mock_index_delete , mock_index_add ) : #NEWLINE# #INDENT# result = BlogPost . index_add_or_delete ( None ) #NEWLINE# self . assertFalse ( result ) #NEWLINE# mock_index_delete . return_value = True #NEWLINE# post = BlogPost . objects . get ( slug = 'DO-NOT-INDEX' ) #NEWLINE# result = BlogPost . index_add_or_delete ( post ) #NEWLINE# self . assertTrue ( result ) #NEWLINE# mock_index_delete . assert_called_with ( post , '' ) #NEWLINE# result = BlogPost . index_add_or_delete ( post , 'foo' ) #NEWLINE# self . assertTrue ( result ) #NEWLINE# mock_index_delete . assert_called_with ( post , 'foo' ) #NEWLINE# mock_index_add . return_value = True #NEWLINE# post = self . latest_post #NEWLINE# result = BlogPost . index_add_or_delete ( post ) #NEWLINE# self . assertTrue ( result ) #NEWLINE# mock_index_add . assert_called_with ( post , '' ) #NEWLINE# result = BlogPost . index_add_or_delete ( post , 'foo' ) #NEWLINE# self . assertTrue ( result ) #NEWLINE# mock_index_add . assert_called_with ( post , 'foo' )