示例#1
0
 def test_highlight_inclusion(self):
     with canned_solr_response_data():
         with self.app.test_request_context():
             resp = solr.query("foo")
             doc = resp.get_doc(0)
             self.assertNotIn('highlights',doc)
             resp = solr.query("foo", highlights=[('abstract',)])
             doc = resp.get_doc(0)
             self.assertIn('highlights',doc)
示例#2
0
 def test_error_response_pagination(self):
     """Tests the get functions in case of an error coming from SOLR"""
     error_response = {"responseHeader":{
                         "status":400,
                         "QTime":1,},
                       "error":{
                         "msg":"org.apache.lucene.queryparser.classic.ParseException: undefined field authsorfsd",
                         "code":400}}
      
     with canned_solr_response_data(error_response):
         with self.app.test_request_context():
             resp = solr.query("foo")
              
             self.assertEqual(resp.get_count(), 0)
             self.assertEqual(resp.get_hits(), 0)
             self.assertEqual(resp.get_start_count(), 0)
              
             #pagination dictionar.y
             pag_dict = {
                    'max_pagination_len': 5 ,
                    'num_total_pages': 0,
                    'current_page': 1,
                    'pages_before': [],
                    'pages_after': [],       
             }
             self.assertEqual(resp.get_pagination(), pag_dict)
示例#3
0
 def test_response_content_with_facets(self):
     with canned_solr_response_data():
         with self.app.test_request_context():
             resp = solr.query("foo", facets=[('year',)])
             resp_data = resp.search_response()
             self.assertIn('facets', resp_data['results'])
             self.assertEqual(resp.get_all_facet_queries(), {'year:[2000 TO 2003]': 13})
             self.assertEqual(resp.get_all_facet_fields(), {'bibstem_facet': ['ApJ', 10, 'ArXiv', 8], 'year': ['2009', 3, '2008', 5]})
示例#4
0
    def test_response_content(self):
        with canned_solr_response_data():
            with self.app.test_request_context():
                resp = solr.query("foo")
                self.assertEqual(resp.get_http_status(), 200)
                self.assertFalse(resp.is_error())

                resp_data = resp.search_response()
                self.assertIn('results', resp_data)
                self.assertNotIn('facets', resp_data['results'])
示例#5
0
 def test_error_response_parsing_02(self):
     #case of possible error string not containg solr class exception    
     error_response = {"responseHeader":{
                         "status":500,
                         "QTime":1,},
                       "error":{"msg":"random string here",
                         "code":500}}
     with canned_solr_response_data(error_response, 500):
         with self.app.test_request_context('/'):
             resp = solr.query("foo")
      
             self.assertEqual(resp.get_http_status(), 500)
             self.assertTrue(resp.is_error())
             self.assertEqual(resp.get_error(), "random string here")
             self.assertEqual(resp.get_error_message(), "random string here")
示例#6
0
 def test_error_response_parsing_01(self):
     """Tests the get functions in case of an error coming from SOLR"""
     #error coming from query parser on SOLR
     error_response = {"responseHeader":{
                         "status":400,
                         "QTime":1,},
                       "error":{"msg":"org.apache.lucene.queryparser.classic.ParseException: undefined field authsorfsd",
                         "code":400}}
     with canned_solr_response_data(error_response, 400):
         with self.app.test_request_context():
             resp = solr.query("foo")
      
             self.assertEqual(resp.get_http_status(), 400)
             self.assertTrue(resp.is_error())
             self.assertEqual(resp.get_error(), "org.apache.lucene.queryparser.classic.ParseException: undefined field authsorfsd")
             self.assertEqual(resp.get_error_message(), "undefined field authsorfsd")