Commit 5e218389 by Chris Dodge Committed by David Baumgold

add ability to do failure testing. If a post passes in a '?fail_at=<num_bytes>'…

add ability to do failure testing. If a post passes in a '?fail_at=<num_bytes>' then the middleware will throw an exception
parent 2832233e
...@@ -3,8 +3,17 @@ import time ...@@ -3,8 +3,17 @@ import time
class DebugFileUploader(FileUploadHandler): class DebugFileUploader(FileUploadHandler):
def __init__(self, request=None):
super(DebugFileUploader, self).__init__(request)
self.count = 0
def receive_data_chunk(self, raw_data, start): def receive_data_chunk(self, raw_data, start):
time.sleep(1) time.sleep(1)
self.count = self.count + len(raw_data)
fail_at = self.request.GET.get('fail_at', None)
if fail_at and self.count > fail_at:
raise Exception('Triggered fail')
return raw_data return raw_data
def file_complete(self, file_size): def file_complete(self, file_size):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment