[Zope-CVS] CVS: Products/Ape/lib/apelib/tests - zope2testbase.py:1.14

Shane Hathaway shane at zope.com
Thu Mar 25 22:32:26 EST 2004


Update of /cvs-repository/Products/Ape/lib/apelib/tests
In directory cvs.zope.org:/tmp/cvs-serv25695/lib/apelib/tests

Modified Files:
	zope2testbase.py 
Log Message:
Augmented the fixed property tests and fixed the breakage.

Some property types are not safely portable to databases, especially
floats and dates.  MySQL, for instance, doesn't have the
date-with-timezone type that Zope 2 needs for storing DateTime objects.
To be safe, the fixed property table code now only creates certain kinds
of columns, placing the rest in the variable properties table.



=== Products/Ape/lib/apelib/tests/zope2testbase.py 1.13 => 1.14 ===
--- Products/Ape/lib/apelib/tests/zope2testbase.py:1.13	Wed Mar 24 23:28:23 2004
+++ Products/Ape/lib/apelib/tests/zope2testbase.py	Thu Mar 25 22:31:53 2004
@@ -33,6 +33,7 @@
 from Products.PythonScripts.PythonScript import PythonScript
 from Products.ZSQLMethods.SQL import manage_addZSQLMethod
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
+from DateTime import DateTime
 
 from apelib.core.interfaces import OIDConflictError
 
@@ -64,10 +65,25 @@
 class FixedSchemaTestFolder(Folder):
 
     _properties = (
-        {'id': 'mytitle', 'type': 'string', 'mode': 'w'},
-        {'id': 'myflag', 'type': 'boolean', 'mode': 'w'},
+        {'id': 'mystring', 'type': 'string', 'mode': 'w'},
+        {'id': 'myfloat', 'type': 'float', 'mode': 'w'},
+        {'id': 'myint', 'type': 'int', 'mode': 'w'},
+        {'id': 'mylong', 'type': 'long', 'mode': 'w'},
+        {'id': 'mydate', 'type': 'date', 'mode': 'w'},
+        {'id': 'mytext', 'type': 'text', 'mode': 'w'},
+        {'id': 'myboolean0', 'type': 'boolean', 'mode': 'w'},
+        {'id': 'myboolean1', 'type': 'boolean', 'mode': 'w'},
         )
 
+    mystring = 'abc'
+    myfloat = 3.14
+    myint = -100
+    mylong = 2L ** 40 + 10
+    mydate = DateTime('2004/03/25')
+    mytext = '987\n654\n321\n'
+    myboolean0 = 0
+    myboolean1 = 1
+
 
 class Zope2TestBase:
 
@@ -328,25 +344,37 @@
 
 
     def test_store_fixed_schema(self):
-        # Test that Ape restores properties of fixed schemas correctly
+        # Test that Ape restores properties of fixed schemas correctly.
+        # (This is a pretty grueling test.)
         conn = self.db.open()
         try:
             app = conn.root()['Application']
             f = FixedSchemaTestFolder()
             f.id = 'Holidays'
-            f.mytitle = 'bah humbug'
-            f.myflag = 1
             app._setObject(f.id, f, set_owner=0)
             get_transaction().commit()
-            f.myflag = 0
+            f.mystring = f.mystring * 2
+            f.myint = f.myint * 2
+            f.mylong = f.mylong * 2
+            f.myfloat = f.myfloat * 2
+            f.mydate = f.mydate + 1
+            f.mytext = f.mytext * 2
+            f.myboolean0 = not f.myboolean0
+            f.myboolean1 = not f.myboolean1
             get_transaction().commit()
 
             conn2 = self.db.open()
             try:
                 app2 = conn2.root()['Application']
                 f2 = app2.Holidays
-                self.assertEqual(f2.mytitle, 'bah humbug')
-                self.assertEqual(f2.myflag, 0)
+                self.assertEqual(f2.mystring, 'abcabc')
+                self.assertEqual(f2.myint, -200)
+                self.assertEqual(f2.mylong, 2L ** 41 + 20)
+                self.assertEqual(f2.myfloat, 6.28)
+                self.assertEqual(f2.mydate, DateTime('2004/03/26'))
+                self.assertEqual(f2.mytext, '987\n654\n321\n987\n654\n321\n')
+                self.assertEqual(f2.myboolean0, 1)
+                self.assertEqual(f2.myboolean1, 0)
             finally:
                 conn2.close()
 




More information about the Zope-CVS mailing list