Ticket #7654: file_uploads_tests.patch

File file_uploads_tests.patch, 2.1 KB (added by Rozza, 16 years ago)

Added Test case - which shows the behaviour

  • tests/regressiontests/file_uploads/views.py

     
    6767    """
    6868    response = file_upload_echo(request)
    6969    request.upload_handlers.insert(0, QuotaUploadHandler())
     70    return response
     71
     72def file_upload_quota_broken_when_looking_at_post(request):
     73    """
     74    You can't change handlers after reading POST; this view shouldn't work.
     75    """
     76    post_copy = request.POST.copy()
     77    request.upload_handlers.insert(0, QuotaUploadHandler())
     78    response = file_upload_echo(request)
    7079    return response
     80 No newline at end of file
  • tests/regressiontests/file_uploads/tests.py

     
    154154            self.client.post,
    155155            '/file_uploads/quota/broken/',
    156156            {'f': open(f.name)}
    157         )       
     157        )
     158   
     159    def test_broken_custom_upload_handler_when_examining_post(self):
     160        f = tempfile.NamedTemporaryFile()
     161        f.write('a' * (2 ** 21))
     162       
     163        # AttributeError: You cannot alter upload handlers after the upload has been processed.
     164        self.assertRaises(
     165            AttributeError,
     166            self.client.post,
     167            '/file_uploads/quota/broken/post/',
     168            {'f': open(f.name)}
     169        )
    158170       
     171 No newline at end of file
  • tests/regressiontests/file_uploads/urls.py

     
    77    (r'^echo/$',            views.file_upload_echo),
    88    (r'^quota/$',           views.file_upload_quota),
    99    (r'^quota/broken/$',    views.file_upload_quota_broken),
     10    (r'^quota/broken/post/$',    views.file_upload_quota_broken_when_looking_at_post),
    1011)
Back to Top