From 5e218389c9f4df6d4a56fa0d282083a55ce7d99f Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 30 May 2013 14:27:50 -0400 Subject: [PATCH] add ability to do failure testing. If a post passes in a '?fail_at=' then the middleware will throw an exception --- cms/djangoapps/contentstore/debug_file_uploader.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cms/djangoapps/contentstore/debug_file_uploader.py b/cms/djangoapps/contentstore/debug_file_uploader.py index aa82b87821..082d21bdbf 100644 --- a/cms/djangoapps/contentstore/debug_file_uploader.py +++ b/cms/djangoapps/contentstore/debug_file_uploader.py @@ -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):