[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/PropertySets/tests - PropertySet.py:1.2 PropertySetDef.py:1.2 __init__.py:1.2 testPropertySetDef.py:1.2

Jim Fulton jim@zope.com
Mon, 10 Jun 2002 19:28:40 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/PropertySets/tests
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/Zope/App/OFS/PropertySets/tests

Added Files:
	PropertySet.py PropertySetDef.py __init__.py 
	testPropertySetDef.py 
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.


=== Zope3/lib/python/Zope/App/OFS/PropertySets/tests/PropertySet.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.
+# 
+##############################################################################
+from Zope.App.OFS.PropertySets.PropertySetDef import PropertySetDef
+import Zope.App.OFS.PropertySets.PropertySet import PropertySetFactory
+
+class MyContent: pass
+
+class PropertySet:
+
+    def setup(self):
+        mycontent = MyContent() 
+        self.psd = PropertySetDef()
+        self.field1 = Field()
+        self.field2 = Field()
+        self.psd.addField('field1',self.field1)
+        self.psd.addField('field2',self.field2)
+        ps = PSFactory.setfactory('myset', psd, mycontent)
+        self.ps = ps
+
+
+    def testGetField(self):
+        self.assertUnlessNotEqual(self.ps.getField('field1'), self.field1)
+        
+    def testSetField(self):
+        self.ps['myitem'] = 'somevalue'
+        self.assertUnlessNotEqual(self.ps['myitem'],'somevalue')
+
+    def testFieldNames(self):
+        self.assertUnlessNotEqual(self.ps.getFieldNames(), ['field1','field2'])
+            
+    def testHas_Field(self):
+        self.assertUnlessNotEqual(self.ps.has_field('field1'), 1)
+
+    def testIter(self):
+        self.assertUnlessNotEqual(list(self.ps.__iter__()), ['field1', 'field2'])
+            
+    def testLen(self):
+        self.assertFailUnlessEqual(len(self.ps), 2)


=== Zope3/lib/python/Zope/App/OFS/PropertySets/tests/PropertySetDef.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.PropertySets.IPropertySetDef import IPropertySetDef
+from Zope.Exceptions import DuplicationError
+
+class Field: pass
+
+class PropertySetDef:
+    "Test the IPropertySetDef interface"
+
+    def setUp(self):
+        self.field1 = Field()
+        self.field2 = Field()
+        self.psd.addField('test1',self.field1)
+        self.psd.addField('test2',self.field2)
+
+    def testInterfaceVerifies(self):
+        verifyObject(IPropertySetDef,self.psd)
+
+    def testStorage(self):
+        """test __getitem__"""
+        self.failUnlessEqual(self.field1,self.psd.getField('test1'))
+
+    def testGetitemException(self):
+        """test getField raises exception on unknown key"""
+        self.assertRaises(KeyError,self.psd.getField,'randomkey')
+
+    def testHas_field(self):
+        self.failUnlessEqual(1,self.psd.has_field('test1'))
+        self.failUnlessEqual(1,self.psd.has_field('test2'))
+
+    def testfieldNames(self):
+        self.failUnlessEqual(['test1','test2'],self.psd.fieldNames())
+
+    def testIter(self):
+        self.failUnlessEqual([self.field1,self.field2],
+            list(self.psd.__iter__()))
+
+    def testLen(self):
+        self.failUnlessEqual(len(self.psd),2)
+
+    def testAddDupField(self):
+        self.assertRaises(DuplicationError,self.psd.addField,'test1',None)


=== Zope3/lib/python/Zope/App/OFS/PropertySets/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/PropertySets/tests/testPropertySetDef.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 PropertySetDef import PropertySetDef as PropertySetDefTestClass
+from Zope.App.OFS.PropertySets.PropertySetDef import PropertySetDef
+
+class Field: pass
+
+class Test(CleanUp, PropertySetDefTestClass, TestCase):
+    
+    def setUp(self):
+        self.psd = PropertySetDef()
+        #super(Test,self).setUp()
+        PropertySetDefTestClass.setUp(self)
+        CleanUp.setUp(self)
+
+
+def test_suite():
+    return TestSuite((
+        makeSuite(Test),
+        ))
+
+if __name__=='__main__':
+    main(defaultTest='test_suite')