[Zope-CVS] CVS: Products/BTreeFolder2/tests -
testBTreeFolder2.py:1.7
Shane Hathaway
shane at zope.com
Mon Feb 9 15:58:35 EST 2004
Update of /cvs-repository/Products/BTreeFolder2/tests
In directory cvs.zope.org:/tmp/cvs-serv8546/tests
Modified Files:
testBTreeFolder2.py
Log Message:
Renamed hasObject to has_key, keeping the old name as an alias.
This fixes a conflict with another product. Also made it possible to
subclass the BTreeFolder2 tests.
=== Products/BTreeFolder2/tests/testBTreeFolder2.py 1.6 => 1.7 ===
--- Products/BTreeFolder2/tests/testBTreeFolder2.py:1.6 Wed Aug 27 10:06:55 2003
+++ Products/BTreeFolder2/tests/testBTreeFolder2.py Mon Feb 9 15:58:34 2004
@@ -27,7 +27,11 @@
from Acquisition import aq_base
-class Tests(unittest.TestCase):
+class BTreeFolder2Tests(unittest.TestCase):
+
+ def getBase(self, ob):
+ # This is overridden in subclasses.
+ return aq_base(ob)
def setUp(self):
self.f = BTreeFolder2('root')
@@ -58,7 +62,7 @@
f2 = Folder()
f2.id = 'subfolder'
self.f._setOb(f2.id, f2)
- mt1 = BTreeFolder2.meta_type
+ mt1 = self.ff.meta_type
mt2 = Folder.meta_type
self.assertEqual(list(self.f.objectIds(mt1)), ['item'])
self.assertEqual(list(self.f.objectIds((mt1,))), ['item'])
@@ -73,7 +77,7 @@
self.assertEqual(len(values), 1)
self.assertEqual(values[0].id, 'item')
# Make sure the object is wrapped.
- self.assert_(values[0] is not aq_base(values[0]))
+ self.assert_(values[0] is not self.getBase(values[0]))
def testObjectItems(self):
items = self.f.objectItems()
@@ -82,11 +86,11 @@
self.assertEqual(id, 'item')
self.assertEqual(val.id, 'item')
# Make sure the object is wrapped.
- self.assert_(val is not aq_base(val))
+ self.assert_(val is not self.getBase(val))
- def testHasObject(self):
- self.assert_(self.f.hasObject('item'))
- self.assert_(self.f.has_key('item'))
+ def testHasKey(self):
+ self.assert_(self.f.hasObject('item')) # Old spelling
+ self.assert_(self.f.has_key('item')) # New spelling
def testDelete(self):
self.f._delOb('item')
@@ -96,7 +100,7 @@
def testObjectMap(self):
map = self.f.objectMap()
self.assertEqual(list(map), [{'id': 'item', 'meta_type':
- BTreeFolder2.meta_type}])
+ self.ff.meta_type}])
# I'm not sure why objectMap_d() exists, since it appears to be
# the same as objectMap(), but it's implemented by Folder.
self.assertEqual(list(self.f.objectMap_d()), list(self.f.objectMap()))
@@ -112,15 +116,16 @@
def testSetObject(self):
f2 = BTreeFolder2('item2')
self.f._setObject(f2.id, f2)
- self.assert_(self.f.hasObject('item2'))
+ self.assert_(self.f.has_key('item2'))
self.assertEqual(self.f.objectCount(), 2)
def testWrapped(self):
- base = aq_base(self.f._getOb('item'))
+ # Verify that the folder returns wrapped versions of objects.
+ base = self.getBase(self.f._getOb('item'))
self.assert_(self.f._getOb('item') is not base)
self.assert_(self.f['item'] is not base)
self.assert_(self.f.get('item') is not base)
- self.assert_(self.f._getOb('item').aq_base is base)
+ self.assert_(self.getBase(self.f._getOb('item')) is base)
def testGenerateId(self):
ids = {}
@@ -146,8 +151,8 @@
old_f._setObject(inner_f.id, inner_f)
self.ff._populateFromFolder(old_f)
self.assertEqual(self.ff.objectCount(), 1)
- self.assert_(self.ff.hasObject('inner'))
- self.assertEqual(aq_base(self.ff._getOb('inner')), inner_f)
+ self.assert_(self.ff.has_key('inner'))
+ self.assertEqual(self.getBase(self.ff._getOb('inner')), inner_f)
def testObjectListing(self):
f2 = BTreeFolder2('somefolder')
@@ -215,9 +220,8 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(Tests),
+ unittest.makeSuite(BTreeFolder2Tests),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
-
More information about the Zope-CVS
mailing list