+ def testResponseConsumerWithGoodResponse(self):
+ """
+ The L{ResponseConsumer} protocol should fire the given L{Deferred} if
+ the given body is a valid Solr response.
+ """
and
+ def testResponseConsumerWithBadResponse(self):
+ """
+ The L{ResponseConsumer} protocol should fire the given L{Deferred} with
+ an C{errback} with L{SolrResponseError} if the decoding fails.
+ """
Please s/L{Deferred}/C{Deferred}/ in these docstrings.
It's better to append the bytes to a list and use ''.join(self.bytes)
when you want the body. Appending to the string will use a lot of
memory unnecessarily.
[1]
+ def testResponseCon sumerWithGoodRe sponse( self):
+ """
+ The L{ResponseConsumer} protocol should fire the given L{Deferred} if
+ the given body is a valid Solr response.
+ """
and
+ def testResponseCon sumerWithBadRes ponse(self) : rror} if the decoding fails.
+ """
+ The L{ResponseConsumer} protocol should fire the given L{Deferred} with
+ an C{errback} with L{SolrResponseE
+ """
Please s/L{Deferred} /C{Deferred} / in these docstrings.
[2]
+ self.assertEqua l(solrResponse. header[ 'status' ], 0) l(solrResponse. header[ 'QTime' ], 2) l(solrResponse. results. numFound, 0) l(len(solrRespo nse.results. docs), 0)
+ self.assertEqua
+ self.assertEqua
+ self.assertEqua
Please reverse the order of the arguments here.
[3]
One minor thing:
def __init__(self, deferred, responseClass):
self.deferred = deferred
self.responseC lass = responseClass
self.body = ''
def dataReceived(self, bytes):
_logger. debug(' Consumer data received:\n' + bytes)
self.body += bytes
It's better to append the bytes to a list and use ''.join(self.bytes)
when you want the body. Appending to the string will use a lot of
memory unnecessarily.
Anyway, this looks good, +1!