Exemple #1
0
 def testImageConstruction(self):
     self.folder.manage_addDTMLMethod('write', file=write_image)
     self.app.REQUEST['id'] = 'foo'
     self.app.REQUEST['file'] = makeFileUpload(gifImage, 'image/gif', 'foo')
     body = self.folder.write(self.folder, self.app.REQUEST)
     self.failUnless(body.find('Ok, done.') >= 0)
     self.failUnless('foo' in self.folder.objectIds())
Exemple #2
0
 def testFileUploadFilename(self):
     upload = makeFileUpload(gifImage, content_type='image/gif')
     self.failUnless(isinstance(upload, FileUpload))
     upload = HTTPUpload(upload, filename='image.gif')
     self.failUnless(isinstance(upload, FileUpload))
     self.assertEqual(upload.headers['content-type'], 'image/gif')
     self.assertEqual(upload.filename, 'image.gif')
     self.failUnless(hasattr(upload, 'read'))
     self.failUnless(hasattr(upload, 'seek'))
 def testFileUploadContentTypeFilename(self):
     upload = makeFileUpload(gifImage, content_type='image/gif')
     self.failUnless(isinstance(upload, FileUpload))
     upload = HTTPUpload(upload, content_type='image/jpeg', filename='image.jpg')
     self.failUnless(isinstance(upload, FileUpload))
     self.assertEqual(upload.headers['content-type'], 'image/jpeg')
     self.assertEqual(upload.filename, 'image.jpg')
     self.failUnless(hasattr(upload, 'read'))
     self.failUnless(hasattr(upload, 'seek'))
 def testFallbackContentTypeWithCharset(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), '',
                                     'text/plain; charset=utf-8')
     self.assertEqual(content_type, 'text/plain')
 def testFallbackContentTypeId(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), 'image.gif',
                                     'image/jpeg')
     # XXX: Id trumps content type here
     self.assertEqual(content_type, 'image/gif')
 def testFallbackId(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), 'image.gif')
     self.assertEqual(content_type, 'image/gif')
 def testContentTypeFilename(self):
     upload = makeFileUpload(gifImage,
                             content_type='image/jpeg',
                             filename='image.gif')
     content_type = get_content_type(upload, upload.read(100), '')
     self.assertEqual(content_type, 'image/jpeg')
 def testDefault(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), '')
     self.assertEqual(content_type, 'application/octet-stream')
 def testFallbackContentTypeWithCharset(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), '', 'text/plain; charset=utf-8')
     self.assertEqual(content_type, 'text/plain')
 def testFallbackContentTypeId(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), 'image.gif', 'image/jpeg')
     # XXX: Id trumps content type here
     self.assertEqual(content_type, 'image/gif')
 def testFallbackId(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), 'image.gif')
     self.assertEqual(content_type, 'image/gif')
 def testContentTypeFilename(self):
     upload = makeFileUpload(gifImage, content_type='image/jpeg', filename='image.gif')
     content_type = get_content_type(upload, upload.read(100), '')
     self.assertEqual(content_type, 'image/jpeg')
 def testDefault(self):
     upload = makeFileUpload(gifImage)
     content_type = get_content_type(upload, upload.read(100), '')
     self.assertEqual(content_type, 'application/octet-stream')