Ticket #7812: inmemoryupload_fileseek_testcases-r7977.patch
File inmemoryupload_fileseek_testcases-r7977.patch, 2.2 KB (added by , 16 years ago) |
---|
-
tests/regressiontests/file_uploads/views.py
78 78 for key in request.FILES.keys(): 79 79 file_counts[key] = len(request.FILES.getlist(key)) 80 80 return HttpResponse(simplejson.dumps(file_counts)) 81 82 def file_upload_not_empty_read(request): 83 "Check that the .read() doesn't return an empty string over uploaded files" 84 for key in request.FILES.keys(): 85 if request.FILES[key].read() == '': 86 return HttpResponseServerError() 87 88 return HttpResponse('') -
tests/regressiontests/file_uploads/tests.py
179 179 180 180 self.assertEqual(got.get('file1'), 1) 181 181 self.assertEqual(got.get('file2'), 2) 182 183 def test_fileupload_seek(self): 184 # small file (under the 5M quota) 185 small_f = tempfile.NamedTemporaryFile() 186 small_f.write('a' * (2 ** 10)) 187 188 response = self.client.post('/file_uploads/notempty/', { 189 'small_f': open(small_f.name) 190 }) 191 self.assertEqual(response.status_code, 200) 192 193 # big file (over the 5M quota) 194 big_f = tempfile.NamedTemporaryFile() 195 big_f.write('a' * (10 * 2 ** 20)) 196 197 response = self.client.post('/file_uploads/notempty/', { 198 'big_': open(big_f.name) 199 }) 200 self.assertEqual(response.status_code, 200) -
tests/regressiontests/file_uploads/urls.py
8 8 (r'^quota/$', views.file_upload_quota), 9 9 (r'^quota/broken/$', views.file_upload_quota_broken), 10 10 (r'^getlist_count/$', views.file_upload_getlist_count), 11 (r'^notempty/$', views.file_upload_not_empty_read), 11 12 )