Exemple #1
0
 def __errcheck(self, rsp):
     if rsp.status != 200:
         ex = SolrConnectionException(rsp.status, rsp.reason)
         try:
             ex.body = rsp.read()
         except:   # pargam: no cover
             pass
         raise ex
     return rsp
    def test_solr_exception(self):
        e = SolrConnectionException(503, "Error happend", "<xml></xml>")

        def test_raise():
            raise e

        self.assertRaisesRegexp(SolrConnectionException,
                                "HTTP code=503, reason=Error happend",
                                test_raise)
        self.assertEqual(
            repr(e), "HTTP code=503, Reason=Error happend, body=<xml></xml>")
Exemple #3
0
 def doSendXML(self, request):
     try:
         rsp = self.doPost(self.solrBase + "/update", request, self.xmlheaders)
         data = rsp.read()
     finally:
         if not self.persistent:
             self.conn.close()
     # detect old-style error response (HTTP response code of
     # 200 with a non-zero status.
     parsed = fromstring(self.decoder(data)[0])
     status = parsed.attrib.get("status", 0)
     if status != 0:
         reason = parsed.documentElement.firstChild.nodeValue
         raise SolrConnectionException(rsp.status, reason)
     return parsed