<s> from __future__ import unicode_literals <EOL> from json import loads <EOL> from django . contrib . auth . models import User <EOL> from django . core . files import File <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import override_settings <EOL> from rest_framework . test import APITestCase <EOL> from documents . models import DocumentType <EOL> from documents . tests import TEST_DOCUMENT_TYPE , TEST_SMALL_DOCUMENT_PATH <EOL> from user_management . tests import ( <EOL> TEST_ADMIN_EMAIL , TEST_ADMIN_PASSWORD , TEST_ADMIN_USERNAME <EOL> ) <EOL> @ override_settings ( OCR_AUTO_OCR = False ) <EOL> class SearchAPITestCase ( APITestCase ) : <EOL> """<STR_LIT>""" <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 . client . force_authenticate ( user = self . admin_user ) <EOL> def test_search ( self ) : <EOL> document_type = DocumentType . objects . create ( <EOL> label = TEST_DOCUMENT_TYPE <EOL> ) <EOL> with open ( TEST_SMALL_DOCUMENT_PATH ) as file_object : <EOL> document = document_type . new_document ( <EOL> file_object = File ( file_object ) , <EOL> ) <EOL> response = self . client . get ( <EOL> '<STR_LIT>' . format ( reverse ( '<STR_LIT>' ) , document . label ) <EOL> ) <EOL> content = loads ( response . content ) <EOL> self . assertEqual ( content [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:label>' ] , document . label ) <EOL> self . assertEqual ( content [ '<STR_LIT:count>' ] , <NUM_LIT:1> ) </s>
