have the test protocol 'fail' on every 3rd message twisty
authorMark Hammond <mhammond@skippinet.com.au>
Mon, 06 Apr 2009 12:12:09 +1000
branchtwisty
changeset 160 e6d1979b6580724c8c77cc44ce0353c58c9d726e
parent 159 d181fa823fbbdcb27eb72395bd4e29ed98eb7e95
child 161 1c9506a81f68d1e66b49218dea3ff3333e1cbeae
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
have the test protocol 'fail' on every 3rd message
server/python/junius/proto/test/__init__.py
--- a/server/python/junius/proto/test/__init__.py
+++ b/server/python/junius/proto/test/__init__.py
@@ -54,17 +54,24 @@ class TestMessageProvider(object):
 
     def saved_bulk_messages(self, result, n):
         logger.debug("Finished saving %d test messages in bulk", n)
         # done
 
 # A 'converter' - takes a proto/test as input and creates a
 # 'raw/message/rfc822' as output.
 class TestConverter(base.ConverterBase):
+    num_converted = 0
     def convert(self, doc):
+        # for the sake of testing the error queue, we cause an error on
+        # every 3rd message we process.
+        self.num_converted += 1
+        if self.num_converted % 3 == 0:
+            raise RuntimeError("This is a test failure")
+
         # for the sake of testing, we fetch the raw attachment just to compare
         # its value.
         return self.doc_model.open_attachment(doc['_id'], "raw-attach",
                   ).addCallback(self._cb_got_attachment, doc)
 
     def _cb_got_attachment(self, attach_content, doc):
         if attach_content != 'test\0blob':
             raise RuntimeError(attach_content)