<s> from __future__ import unicode_literals <EOL> import datetime <EOL> import pytz <EOL> import unittest <EOL> import os . path <EOL> import scorched . response <EOL> class ResultsTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> file = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> with open ( file ) as f : <EOL> self . data = f . read ( ) <EOL> file = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> with open ( file ) as f : <EOL> self . data_tv = f . read ( ) <EOL> file = os . path . join ( os . path . dirname ( __file__ ) , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> with open ( file ) as f : <EOL> self . data_error = f . read ( ) <EOL> def test_response ( self ) : <EOL> res = scorched . response . SolrResponse . from_json ( <EOL> self . data , datefields = ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( res . status , <NUM_LIT:0> ) <EOL> self . assertEqual ( res . QTime , <NUM_LIT:1> ) <EOL> self . assertEqual ( res . result . numFound , <NUM_LIT:3> ) <EOL> self . assertEqual ( [ x [ '<STR_LIT:name>' ] for x in res ] , <EOL> [ u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u"<STR_LIT>" ] ) <EOL> self . assertEqual ( [ x [ '<STR_LIT:name>' ] for x in res . result . docs ] , <EOL> [ u'<STR_LIT>' , <EOL> u'<STR_LIT>' , <EOL> u"<STR_LIT>" ] ) <EOL> self . assertEqual ( [ x [ '<STR_LIT>' ] for x in res . result . docs if '<STR_LIT>' in x ] , <EOL> [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> tzinfo = pytz . utc ) ] ) <EOL> self . assertEqual ( [ x [ '<STR_LIT>' ] for x in res . result . docs if '<STR_LIT>' in x ] , <EOL> [ datetime . datetime ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> tzinfo = pytz . utc ) ] ) <EOL> self . assertEqual ( res . facet_counts . __dict__ , <EOL> { '<STR_LIT>' : { u'<STR_LIT>' : [ ( u'<STR_LIT>' , <NUM_LIT:3> ) , <EOL> ( u'<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ( u'<STR_LIT>' , <NUM_LIT:1> ) ] } , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { <EOL> u'<STR_LIT>' : { <EOL> u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT:start>' : u'<STR_LIT>' , <EOL> u'<STR_LIT:end>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : [ <EOL> ( u'<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( u'<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( u'<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ] <EOL> } , <EOL> } , <EOL> '<STR_LIT>' : ( ) } ) <EOL> res_tv = scorched . response . SolrResponse . from_json ( <EOL> self . data_tv , datefields = ( '<STR_LIT:date>' ) ) <EOL> self . assertEqual ( res_tv . term_vectors [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( res_tv . term_vectors [ "<STR_LIT>" ] , <EOL> { "<STR_LIT>" : [ "<STR_LIT:title>" ] } ) <EOL> self . assertEqual ( res_tv . term_vectors [ "<STR_LIT>" ] [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( res_tv . term_vectors [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , <EOL> { "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : <NUM_LIT> } ) <EOL> self . assertEqual ( res_tv . term_vectors [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , <EOL> { "<STR_LIT>" : <NUM_LIT:3> , "<STR_LIT>" : <NUM_LIT> } ) <EOL> self . assertRaises ( ValueError , res . from_json , self . data_error ) <EOL> self . assertEqual ( res . __str__ ( ) , u'<STR_LIT>' ) <EOL> self . assertEqual ( len ( res ) , <NUM_LIT:3> ) </s>
