[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/RDB/tests - testRow.py:1.4 testSQLCommand.py:1.6

Albertas Agejevas alga@codeworks.lt
Mon, 2 Dec 2002 15:03:52 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/RDB/tests
In directory cvs.zope.org:/tmp/cvs-serv5490/lib/python/Zope/App/RDB/tests

Modified Files:
	testRow.py testSQLCommand.py 
Log Message:
Added stats reporting to the RAMCache.
Had to make Zope.App.RDB.ResultSet pickleable on the way.
Renamed ResultSet.names to ResultSet.columns.
Updated SQLScript to pass the location to the cache, not self.


=== Zope3/lib/python/Zope/App/RDB/tests/testRow.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/RDB/tests/testRow.py:1.3	Wed Jul 17 12:54:19 2002
+++ Zope3/lib/python/Zope/App/RDB/tests/testRow.py	Mon Dec  2 15:03:50 2002
@@ -11,55 +11,77 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""XXX short summary goes here.
-
-XXX longer description goes here.
+"""Row class tests.
 
 $Id$
 """
 
-from Zope.App.RDB.Row import RowClassFactory
-from Zope.Security.Proxy import ProxyFactory
-from Zope.Exceptions import ForbiddenAttribute
-
 from unittest import TestCase, TestSuite, main, makeSuite
 
 class RowTests(TestCase):
 
-    def test_row_klass_creation(self):
+    def test_RowClassFactory(self):
+        from Zope.App.RDB.Row import RowClassFactory
 
         columns = ('food', 'name')
         data = ('pizza', 'john')
-        
+
         klass = RowClassFactory(columns)
         ob = klass(data)
-        
-        self.failUnless(ob.food == 'pizza',
-                        """bad row class attribute""")
 
-        self.failUnless(ob.name == 'john',
-                        """bad row class attribute (2)""")        
+        self.failUnless(ob.food == 'pizza', "bad row class attribute")
+        self.failUnless(ob.name == 'john', "bad row class attribute (2)")
 
-    def test_row_klass_security_declarations(self):
+    def test_RowClassFactory_Proxied(self):
+        from Zope.App.RDB.Row import RowClassFactory
+        from Zope.Security.Proxy import ProxyFactory
+        from Zope.Exceptions import ForbiddenAttribute
 
         columns = ('type', 'speed')
         data = ('airplane', '800km')
-        
+
         klass = RowClassFactory(columns)
 
         ob = klass(data)
 
         proxied = ProxyFactory(ob)
 
-        self.failUnless (proxied.type == 'airplane',
-                         """ security proxy error""")
-
-        self.failUnless (proxied.speed == '800km',
-                         """ security proxy error (2)""")        
+        self.failUnless (proxied.type == 'airplane', "security proxy error")
+        self.failUnless (proxied.speed == '800km', "security proxy error (2)")
 
         self.assertRaises(ForbiddenAttribute,
                           lambda x=proxied: x.__slots__
                           )
+
+    def test__cmp__(self):
+        from Zope.App.RDB.Row import RowClassFactory
+
+        columns = ('food', 'name')
+        data = ('pizza', 'john')
+
+        klass = RowClassFactory(columns)
+        ob = klass(data)
+        self.assertEqual(ob, ob, "not equal to self")
+
+        klass2 = RowClassFactory(columns)
+        ob2 = klass2(data)
+        self.assertEqual(ob, ob2, "not equal to an identical class")
+
+        columns = ('food', 'surname')
+        data = ('pizza', 'john')
+
+        klass3 = RowClassFactory(columns)
+        ob3 = klass3(data)
+        self.assert_(ob < ob3, "cmp with different columns")
+
+        columns = ('food', 'name')
+        data = ('pizza', 'mary')
+
+        klass4 = RowClassFactory(columns)
+        ob4 = klass4(data)
+        self.assert_(ob < ob4, "cmp with different data")
+
+
 
 def test_suite():
     return makeSuite(RowTests)


=== Zope3/lib/python/Zope/App/RDB/tests/testSQLCommand.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/App/RDB/tests/testSQLCommand.py:1.5	Fri Oct  4 14:37:24 2002
+++ Zope3/lib/python/Zope/App/RDB/tests/testSQLCommand.py	Mon Dec  2 15:03:50 2002
@@ -77,7 +77,7 @@
     def testSimpleSQLCommand(self):
         command = SQLCommand("my_connection", "SELECT id FROM Table")
         result = command()
-        self.assertEqual(result.names, ('id',))
+        self.assertEqual(result.columns, ('id',))
         self.assertEqual(result[0].id, 1)