Skip to content

Commit

Permalink
fix some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed May 25, 2018
1 parent 3214250 commit 0224a5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
23 changes: 13 additions & 10 deletions plone/app/caching/tests/test_profile_with_caching_proxy.py
Expand Up @@ -17,7 +17,6 @@
from plone.testing.z2 import Browser
from Products.CMFCore.FSFile import FSFile
from Products.CMFCore.utils import getToolByName
from six.moves import cStringIO as StringIO
from zope.component import getUtility
from zope.globalrequest import setRequest

Expand All @@ -26,6 +25,7 @@
import dateutil.tz
import os
import pkg_resources
import six
import unittest


Expand Down Expand Up @@ -89,7 +89,7 @@ def setUp(self):
def tearDown(self):
setRequest(None)

def test_composite_views(self):
def test_composite_viewsxx(self):
# This is a clone of the same test for 'without-caching-proxy'
# Can we just call that test from this context?

Expand Down Expand Up @@ -213,11 +213,12 @@ def test_composite_views(self):
browser.open(self.portal['f1']['d1'].absolute_url())
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request the anonymous folder
now = stable_now()
browser = Browser(self.app)
browser.handleErrors = False
browser.open(self.portal['f1'].absolute_url())
self.assertEqual('plone.content.folderView',
browser.headers['X-Cache-Rule'])
Expand Down Expand Up @@ -280,7 +281,7 @@ def test_composite_views(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Edit the page to update the etag
testText2 = 'Testing... body two'
Expand Down Expand Up @@ -373,7 +374,7 @@ def test_content_feeds(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request the authenticated rss feed
now = stable_now()
Expand Down Expand Up @@ -503,7 +504,7 @@ def test_content_files(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request an image scale
now = stable_now()
Expand Down Expand Up @@ -554,17 +555,19 @@ def test_resources(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request a large datafile (over 64K) to test files that use
# the "response.write()" function to initiate a streamed response.
# This is of type OFS.Image.File but it should also apply to
# large OFS.Image.Image, large non-blog ATImages/ATFiles, and
# large Resource Registry cooked files, which all use the same
# method to initiate a streamed response.
s = 'a' * (1 << 16) * 3
self.portal.manage_addFile('bigfile', file=StringIO(
s), content_type='application/octet-stream')
s = b'a' * (1 << 16) * 3
self.portal.manage_addFile(
'bigfile',
file=six.BytesIO(s),
content_type='application/octet-stream')

import transaction
transaction.commit()
Expand Down
20 changes: 11 additions & 9 deletions plone/app/caching/tests/test_profile_without_caching_proxy.py
Expand Up @@ -14,7 +14,6 @@
from plone.testing.z2 import Browser
from Products.CMFCore.FSFile import FSFile
from Products.CMFCore.utils import getToolByName
from six.moves import cStringIO as StringIO
from zope.component import getUtility
from zope.globalrequest import setRequest

Expand All @@ -23,6 +22,7 @@
import dateutil.tz
import os
import pkg_resources
import six
import unittest


Expand Down Expand Up @@ -214,7 +214,7 @@ def test_composite_views(self):
browser.open(self.portal['f1']['d1'].absolute_url())
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request the anonymous folder
now = stable_now()
Expand Down Expand Up @@ -281,7 +281,7 @@ def test_composite_views(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Edit the page to update the etag
testText2 = 'Testing... body two'
Expand Down Expand Up @@ -367,7 +367,7 @@ def test_content_feeds(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request the authenticated rss feed
now = stable_now()
Expand Down Expand Up @@ -453,7 +453,7 @@ def test_content_files(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request an image scale
now = stable_now()
Expand Down Expand Up @@ -502,17 +502,19 @@ def test_resources(self):
browser.headers['X-Cache-Operation'])
# This should be a 304 response
self.assertEqual('304 Not Modified', browser.headers['Status'])
self.assertEqual('', browser.contents)
self.assertEqual(b'', browser.contents)

# Request a large datafile (over 64K) to test files that use
# the "response.write()" function to initiate a streamed response.
# This is of type OFS.Image.File but it should also apply to
# large OFS.Image.Image, large non-blog ATImages/ATFiles, and
# large Resource Registry cooked files, which all use the same
# method to initiate a streamed response.
s = 'a' * (1 << 16) * 3
self.portal.manage_addFile('bigfile', file=StringIO(
s), content_type='application/octet-stream')
s = b'a' * (1 << 16) * 3
self.portal.manage_addFile(
'bigfile',
file=six.BytesIO(s),
content_type='application/octet-stream')

import transaction
transaction.commit()
Expand Down

0 comments on commit 0224a5d

Please sign in to comment.