[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Annotation/tests - Annotations.py:1.2 __init__.py:1.2 testAttributeAnnotations.py:1.2
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:28:22 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Annotation/tests
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/Annotation/tests
Added Files:
Annotations.py __init__.py testAttributeAnnotations.py
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/Zope/App/OFS/Annotation/tests/Annotations.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+
+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')
=== Zope3/lib/python/Zope/App/OFS/Annotation/tests/__init__.py 1.1 => 1.2 ===
+#
+# 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.
+#
+##############################################################################
=== Zope3/lib/python/Zope/App/OFS/Annotation/tests/testAttributeAnnotations.py 1.1 => 1.2 ===
+#
+# 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$
+"""
+
+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')