Ticket #7812: r8007-seek-testcase.patch
File r8007-seek-testcase.patch, 2.5 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 """ 84 Check that the first .read() returns the whole file (because we don't specify 85 the size to read, so we read the entire file), while the second returns an 86 empty string 87 """ 88 for key in request.FILES.keys(): 89 if request.FILES[key].read() == '': 90 return HttpResponseServerError() 91 if request.FILES[key].read() != '': 92 return HttpResponseServerError() 93 94 return HttpResponse('') -
tests/regressiontests/file_uploads/tests.py
187 187 self.assertEqual(got.get('file1'), 1) 188 188 self.assertEqual(got.get('file2'), 2) 189 189 190 def test_fileupload_seek(self): 191 # small file (under the 5M quota) 192 small_f = tempfile.NamedTemporaryFile() 193 small_f.write('a' * (2 ** 10)) 194 195 response = self.client.post('/file_uploads/notempty/', { 196 'small_f': open(small_f.name) 197 }) 198 self.assertEqual(response.status_code, 200) 199 200 # big file (over the 5M quota) 201 big_f = tempfile.NamedTemporaryFile() 202 big_f.write('a' * (10 * 2 ** 20)) 203 204 response = self.client.post('/file_uploads/notempty/', { 205 'big_f': open(big_f.name) 206 }) 207 self.assertEqual(response.status_code, 200) 208 190 209 class DirectoryCreationTests(unittest.TestCase): 191 210 """ 192 211 Tests for error handling during directory creation -
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 )