Skip to content

Commit

Permalink
fix tests from r22134 merged in r29767 works with Plone 2.5.5
Browse files Browse the repository at this point in the history
svn path=/plone.app.blob/branches/plone-2.5-support/; revision=29768
  • Loading branch information
vincic committed Sep 17, 2009
1 parent 6b7fc8a commit 6ed4f02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions plone/app/blob/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ instantiable:
>>> portal_types.getTypeInfo('Blob')
<DynamicViewTypeInformation at /plone/portal_types/Blob>

>>> self.setRoles(['Manager'])
>>> folder.invokeFactory('Blob', id='blob', title='a Blob')
'blob'
>>> blob = folder.blob
Expand Down Expand Up @@ -133,7 +134,7 @@ or wrong data from showing up in some views, i.e. folder listing:
Finally the correct creation of blob-based content "through the web" is tested
using a testbrowser:

>>> self.setRoles('Editor')
>>> self.setRoles('Manager')
>>> from Products.Five.testbrowser import Browser
>>> from Products.PloneTestCase import PloneTestCase as ptc
>>> user, pwd = ptc.default_user, ptc.default_password
Expand All @@ -150,8 +151,8 @@ using a testbrowser:
>>> control.value = StringIO('%PDF-1.4 fake pdf...' + 'foo' * 1000)
>>> browser.getControl('Save').click()
>>> browser.url
'http://nohost/plone/.../foo.pdf/view'
'http://nohost/plone/.../foo.pdf/view?portal_status_message=Changes%20saved.'
>>> browser.contents
'...Info...Changes saved...
...Foo...foo.pdf...PDF document,...2Kb...'
'...Changes saved...
...Foo...pdf.png...2.9 kB...'

15 changes: 12 additions & 3 deletions plone/app/blob/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import os.path
from unittest import TestSuite, makeSuite
from Testing.ZopeTestCase import installPackage, ZopeDocFileSuite
from Testing.ZopeTestCase import ZopeDocFileSuite
from ZPublisher.HTTPRequest import HTTPRequest
from Products.Five import zcml
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import onsetup

from plone.app.blob.utils import guessMimetype
from plone.app.blob.utils import guessMimetype as guessMimetypeHelper

from StringIO import StringIO
from base64 import decodestring
Expand All @@ -23,7 +23,14 @@ def setupPackage():
import plone.app.blob
zcml.load_config('configure.zcml', plone.app.blob)
fiveconfigure.debug_mode = False
installPackage('plone.app.blob')

# make sure the monkey patches from `pythonproducts` are appied; they get
# loaded with an `installProduct('Five')`, but zcml layer's `setUp()`
# calls `five.safe_load_site()`, which in turn calls `cleanUp()` from
# `zope.testing.cleanup`, effectively removing the patches again *before*
# the tests are run; so we need to explicitly apply them again... %)
from Products.Five import pythonproducts
pythonproducts.applyPatches()

setupPackage()
PloneTestCase.setupPloneSite(extension_profiles=(
Expand Down Expand Up @@ -69,6 +76,8 @@ def testFileName(self):
self.assert_(os.path.isfile(f.name))

def testMimetypeGuessing(self):
def guessMimetype(data, filename=None):
return guessMimetypeHelper(data, filename, context=self.portal)
gif = StringIO(decodestring(self.gif))
self.assertEqual(guessMimetype(gif), 'image/gif')
self.assertEqual(guessMimetype(gif, 'image.jpg'), 'image/jpeg')
Expand Down

0 comments on commit 6ed4f02

Please sign in to comment.