<s> from __future__ import unicode_literals <EOL> from django . contrib . auth . models import User <EOL> from django . core . files . base import File <EOL> from django . test import TestCase <EOL> from documents . models import DocumentType <EOL> from documents . search import document_search <EOL> from documents . tests import TEST_DOCUMENT_TYPE , TEST_SMALL_DOCUMENT_PATH <EOL> from user_management . tests import ( <EOL> TEST_ADMIN_PASSWORD , TEST_ADMIN_USERNAME , TEST_ADMIN_EMAIL <EOL> ) <EOL> class DocumentSearchTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . admin_user = User . objects . create_superuser ( <EOL> username = TEST_ADMIN_USERNAME , email = TEST_ADMIN_EMAIL , <EOL> password = TEST_ADMIN_PASSWORD <EOL> ) <EOL> self . document_type = DocumentType . objects . create ( <EOL> label = TEST_DOCUMENT_TYPE <EOL> ) <EOL> with open ( TEST_SMALL_DOCUMENT_PATH ) as file_object : <EOL> self . document = self . document_type . new_document ( <EOL> file_object = File ( file_object ) , label = '<STR_LIT>' <EOL> ) <EOL> def tearDown ( self ) : <EOL> self . document_type . delete ( ) <EOL> def test_simple_search_after_related_name_change ( self ) : <EOL> """<STR_LIT>""" <EOL> model_list , result_set , elapsed_time = document_search . search ( <EOL> { '<STR_LIT:q>' : '<STR_LIT>' } , user = self . admin_user <EOL> ) <EOL> self . assertEqual ( len ( result_set ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( model_list ) , [ self . document ] ) <EOL> def test_advanced_search_after_related_name_change ( self ) : <EOL> model_list , result_set , elapsed_time = document_search . search ( <EOL> { '<STR_LIT:label>' : self . document . label } , user = self . admin_user <EOL> ) <EOL> self . assertEqual ( len ( result_set ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( model_list ) , [ self . document ] ) <EOL> model_list , result_set , elapsed_time = document_search . search ( <EOL> { '<STR_LIT>' : self . document . file_mimetype } , <EOL> user = self . admin_user <EOL> ) <EOL> self . assertEqual ( len ( result_set ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( list ( model_list ) , [ self . document ] ) </s>
