Skip to content

Commit

Permalink
Merge pull request #2538 from plone/2526-dx-document-size
Browse files Browse the repository at this point in the history
Fix DX document size for Python 3
  • Loading branch information
pbauer authored Oct 1, 2018
2 parents 972d91a + 3bfb322 commit c7c3243
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ New features:

Bug fixes:

- Fixed getObjSize indexer for Python 3. #2526
[reinhardt]

- Remove the devdependencies from bower.json - they are just used for running tests in mockup, not here.
[sunew]

Expand Down
2 changes: 1 addition & 1 deletion Products/CMFPlone/CatalogTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def getObjSize(obj):
if size < SIZE_CONST[smaller]:
return '1 %s' % smaller
for c in SIZE_ORDER:
if size / SIZE_CONST[c] > 0:
if size // SIZE_CONST[c] > 0:
break
return '%.1f %s' % (float(size / float(SIZE_CONST[c])), c)
return size
Expand Down
10 changes: 8 additions & 2 deletions Products/CMFPlone/tests/testCatalogTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,14 +1303,20 @@ def test_provided(self):
self.assertTrue(IIndexableObjectWrapper.providedBy(w))
self.assertTrue(IContentish.providedBy(w))

def test_getObjSize(self):
def test_getObjSize_KB(self):
from Products.CMFPlone.CatalogTool import getObjSize
get_size = getObjSize.callable
# FIXME: getObjSize die not count text in DX
self.doc.text = RichTextValue('a' * 1000)
self.doc.reindexObject()
self.assertEqual(get_size(self.doc), '1 KB')

def test_getObjSize_MB(self):
from Products.CMFPlone.CatalogTool import getObjSize
get_size = getObjSize.callable
self.doc.text = RichTextValue('a' * 6000000)
self.doc.reindexObject()
self.assertEqual(get_size(self.doc), '5.7 MB')

def test_uuid(self):
alsoProvides(self.doc, IAttributeUUID)
notify(ObjectCreatedEvent(self.doc))
Expand Down

0 comments on commit c7c3243

Please sign in to comment.