add ability to do failure testing. If a post passes in a '?fail_at=<num_bytes>' then the middleware will throw an exception
This commit is contained in:
committed by
David Baumgold
parent
2832233eb9
commit
5e218389c9
@@ -3,8 +3,17 @@ import time
|
||||
|
||||
|
||||
class DebugFileUploader(FileUploadHandler):
|
||||
def __init__(self, request=None):
|
||||
super(DebugFileUploader, self).__init__(request)
|
||||
self.count = 0
|
||||
|
||||
def receive_data_chunk(self, raw_data, start):
|
||||
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
|
||||
|
||||
def file_complete(self, file_size):
|
||||
|
||||
Reference in New Issue
Block a user