[Zope-CVS] CVS: Products/BTreeFolder2/tests - testBTreeFolder2.py:1.3
Shane Hathaway
shane@cvs.zope.org
Wed, 8 May 2002 14:55:12 -0400
Update of /cvs-repository/Products/BTreeFolder2/tests
In directory cvs.zope.org:/tmp/cvs-serv7591/tests
Modified Files:
testBTreeFolder2.py
Log Message:
Added batching, removed unused code, and added tests.
=== Products/BTreeFolder2/tests/testBTreeFolder2.py 1.2 => 1.3 ===
self.assertEqual(lst, ['item', 'item3'])
-## def testIdsWithMetaType(self):
-## mt = BTreeFolder2.meta_type
-## self.assertEqual(list(self.f.objectIds(mt)), ['item'])
-## self.assertEqual(list(self.f.objectIds('blah')), [])
-
def testValues(self):
values = self.f.objectValues()
self.assertEqual(len(values), 1)
@@ -90,12 +85,6 @@
# the same as objectMap(), but it's implemented by Folder.
self.assertEqual(list(self.f.objectMap_d()), list(self.f.objectMap()))
-## def testObjectsAttribute(self):
-## # _objects is needed by superValues().
-## self.assertEqual(list(self.f._objects), list(self.f.objectMap()))
-## self.f._delOb('item')
-## self.assertEqual(list(self.f._objects), [])
-
def testObjectIds_d(self):
self.assertEqual(self.f.objectIds_d(), {'item': 1})
@@ -125,10 +114,6 @@
for id in ids.keys():
self.f._checkId(id) # Must all be valid
-## def testSuperValues(self):
-## lst = list(self.f['item'].superValues('BTreeFolder2'))
-## self.assertEqual(len(lst), 1)
-
def testReplace(self):
old_f = Folder()
old_f.id = 'item'
@@ -139,6 +124,36 @@
self.assert_(self.ff.hasObject('inner'))
self.assertEqual(aq_base(self.ff._getOb('inner')), inner_f)
+ def testObjectListing(self):
+ f2 = BTreeFolder2('somefolder')
+ self.f._setObject(f2.id, f2)
+ # Hack in an absolute_url() method that works without context.
+ self.f.absolute_url = lambda: ''
+ info = self.f.getBatchObjectListing()
+ self.assertEqual(info['b_start'], 1)
+ self.assertEqual(info['b_end'], 2)
+ self.assertEqual(info['prev_batch_url'], '')
+ self.assertEqual(info['next_batch_url'], '')
+ self.assert_(info['formatted_list'].find('</select>') > 0)
+ self.assert_(info['formatted_list'].find('item') > 0)
+ self.assert_(info['formatted_list'].find('somefolder') > 0)
+
+ # Ensure batching is working.
+ info = self.f.getBatchObjectListing({'b_count': 1})
+ self.assertEqual(info['b_start'], 1)
+ self.assertEqual(info['b_end'], 1)
+ self.assertEqual(info['prev_batch_url'], '')
+ self.assert_(info['next_batch_url'] != '')
+ self.assert_(info['formatted_list'].find('item') > 0)
+ self.assert_(info['formatted_list'].find('somefolder') < 0)
+
+ info = self.f.getBatchObjectListing({'b_start': 2})
+ self.assertEqual(info['b_start'], 2)
+ self.assertEqual(info['b_end'], 2)
+ self.assert_(info['prev_batch_url'] != '')
+ self.assertEqual(info['next_batch_url'], '')
+ self.assert_(info['formatted_list'].find('item') < 0)
+ self.assert_(info['formatted_list'].find('somefolder') > 0)
def test_suite():