Ticket #9591: 9591-test.diff
File 9591-test.diff, 2.2 KB (added by , 16 years ago) |
---|
-
tests/regressiontests/file_uploads/views.py
4 4 from django.utils import simplejson 5 5 from models import FileModel 6 6 from uploadhandler import QuotaUploadHandler, ErroringUploadHandler 7 from django.core.files.uploadhandler import MemoryFileUploadHandler 7 8 from django.utils.hashcompat import sha_constructor 8 9 from tests import UNICODE_FILENAME 9 10 … … 111 112 def file_upload_errors(request): 112 113 request.upload_handlers.insert(0, ErroringUploadHandler()) 113 114 return file_upload_echo(request) 115 116 def file_upload_memory_position(request): 117 request.upload_handlers.insert(0, MemoryFileUploadHandler()) 118 return HttpResponse(str(request.FILES['file_field'].tell())) 119 -
tests/regressiontests/file_uploads/tests.py
249 249 # CustomUploadError is the error that should have been raised 250 250 self.assertEqual(err.__class__, uploadhandler.CustomUploadError) 251 251 252 def test_memory_position(self): 253 post_data = { 254 'name': 'Ringo', 255 'file_field': open(__file__), 256 } 257 response = self.client.post('/file_uploads/memory_position/', post_data) 258 self.assertEqual(response.content, "0") 259 252 260 class DirectoryCreationTests(unittest.TestCase): 253 261 """ 254 262 Tests for error handling during directory creation -
tests/regressiontests/file_uploads/urls.py
10 10 (r'^quota/broken/$', views.file_upload_quota_broken), 11 11 (r'^getlist_count/$', views.file_upload_getlist_count), 12 12 (r'^upload_errors/$', views.file_upload_errors), 13 (r'^memory_position/$', views.file_upload_memory_position), 13 14 ) 15