[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Annotation/tests - Annotations.py:1.1.2.1 __init__.py:1.1.2.1 testAttributeAnnotations.py:1.1.2.1
Steve Alexander
steve@cat-box.net
Sun, 26 May 2002 12:10:27 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Annotation/tests
In directory cvs.zope.org:/tmp/cvs-serv3979/lib/python/Zope/App/OFS/Annotation/tests
Added Files:
Tag: Zope-3x-branch
Annotations.py __init__.py testAttributeAnnotations.py
Log Message:
Changed MementoBag to Annotations as per collector issue 66
http://collector.zope.org/Zope3-dev/66
Note that this will break pre-existing __memobag__ attributes in
persistent objects.
=== Added File Zope3/lib/python/Zope/App/OFS/Annotation/tests/Annotations.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Revision information:
$Id: Annotations.py,v 1.1.2.1 2002/05/26 16:10:25 stevea Exp $
"""
from Interface.Verify import verifyObject
from Zope.App.OFS.Annotation.IAnnotations import IAnnotations
class Annotations:
"""
Test the IAnnotations interface. Expects the IAnnotations
to be in self.annotations
"""
def setUp(self):
self.obj = {1:2, 3:4}
def testInterfaceVerifies(self):
verifyObject(IAnnotations, self.annotations)
def testStorage(self):
"""test __getitem__"""
self.annotations['unittest'] = self.obj
res = self.annotations['unittest']
self.failUnlessEqual(self.obj, res)
def testGetitemException(self):
"""test __getitem raises exception on unknown key"""
self.assertRaises(KeyError, self.annotations.__getitem__,'randomkey')
def testGet(self):
"""test get"""
self.annotations['unittest'] = obj
res = self.annotations.get('unittest')
self.failUnlessEqual(obj, res)
def testGet(self):
"""test get with no set"""
res = self.annotations.get('randomkey')
self.failUnlessEqual(None, res)
def testGetDefault(self):
"""test get returns default"""
res = self.annotations.get('randomkey', 'default')
self.failUnlessEqual('default', res)
def testDel(self):
self.annotations['unittest'] = self.obj
del self.annotations['unittest']
self.failUnlessEqual(None, self.annotations.get('unittest'))
def testDelRaisesKeyError(self):
self.assertRaises(KeyError, self.annotations.__delitem__, 'unittest')
=== Added File Zope3/lib/python/Zope/App/OFS/Annotation/tests/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
=== Added File Zope3/lib/python/Zope/App/OFS/Annotation/tests/testAttributeAnnotations.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Revision information:
$Id: testAttributeAnnotations.py,v 1.1.2.1 2002/05/26 16:10:25 stevea Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
from Annotations import Annotations
from Zope.App.OFS.Annotation.AttributeAnnotations import AttributeAnnotations
from Zope.App.OFS.Annotation.IAttributeAnnotatable \
import IAttributeAnnotatable
class Dummy:
__implements__ = IAttributeAnnotatable
class Test(CleanUp, Annotations, TestCase):
def setUp(self):
self.annotations = AttributeAnnotations(Dummy())
#super(Test,self).setUp()
Annotations.setUp(self)
CleanUp.setUp(self)
def test_suite():
return TestSuite((
makeSuite(Test),
))
if __name__=='__main__':
main(defaultTest='test_suite')