[Zope3-checkins] CVS: Zope3/src/zope/app/rdb/tests - test_dsnparser.py:1.2.26.1 test_row.py:1.3.10.1 test_sqlcommand.py:1.4.18.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:23 -0400
Update of /cvs-repository/Zope3/src/zope/app/rdb/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/rdb/tests
Modified Files:
Tag: cw-mail-branch
test_dsnparser.py test_row.py test_sqlcommand.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/app/rdb/tests/test_dsnparser.py 1.2 => 1.2.26.1 ===
--- Zope3/src/zope/app/rdb/tests/test_dsnparser.py:1.2 Wed Dec 25 09:13:14 2002
+++ Zope3/src/zope/app/rdb/tests/test_dsnparser.py Sun Jun 22 10:23:21 2003
@@ -39,6 +39,12 @@
'password': 'muster', 'host': '', 'port': ''}
self.assertEqual(result, parseDSN(dsn))
+ def testPasswordWithColon(self):
+ dsn = 'dbi://mike:before:after/test'
+ result = {'parameters': {}, 'dbname': 'test', 'username': 'mike',
+ 'password': 'before:after', 'host': '', 'port': ''}
+ self.assertEqual(result, parseDSN(dsn))
+
def testUserPasswordAndParams(self):
dsn = 'dbi://mike:muster/test;param1=value1;param2=value2'
result = {'parameters': {'param1': 'value1', 'param2': 'value2'},
@@ -60,8 +66,8 @@
self.assertEqual(result, parseDSN(dsn))
def testFailures(self):
- self.assertRaises(AssertionError, parseDSN, None)
- self.assertRaises(AssertionError, parseDSN, 'dfi://')
+ self.assertRaises(ValueError, parseDSN, None)
+ self.assertRaises(ValueError, parseDSN, 'dfi://')
def test_suite():
suite = unittest.TestSuite()
=== Zope3/src/zope/app/rdb/tests/test_row.py 1.3 => 1.3.10.1 ===
--- Zope3/src/zope/app/rdb/tests/test_row.py:1.3 Thu May 1 15:35:30 2003
+++ Zope3/src/zope/app/rdb/tests/test_row.py Sun Jun 22 10:23:21 2003
@@ -36,6 +36,7 @@
from zope.app.rdb import RowClassFactory
from zope.security.proxy import ProxyFactory
from zope.exceptions import ForbiddenAttribute
+ from zope.security.interfaces import IChecker
columns = ('type', 'speed')
data = ('airplane', '800km')
@@ -48,10 +49,18 @@
self.failUnless (proxied.type == 'airplane', "security proxy error")
self.failUnless (proxied.speed == '800km', "security proxy error (2)")
+ self.assertRaises(ForbiddenAttribute, getattr, proxied, '__slots__')
- self.assertRaises(ForbiddenAttribute,
- lambda x=proxied: x.__slots__
- )
+ # Indirectly, check the the __Security_checker__ attribute has been
+ # applied only to the instance, and not to the class.
+ self.assertRaises(ForbiddenAttribute, getattr, proxied, '__bases__')
+ proxied_class = ProxyFactory(klass)
+ proxied_class.__bases__
+
+ # Check __Security_checker__ directly
+ self.assertRaises(AttributeError,
+ getattr, klass, '__Security_checker__')
+ self.assert_(IChecker.isImplementedBy(ob.__Security_checker__))
def test__cmp__(self):
from zope.app.rdb import RowClassFactory
@@ -81,6 +90,23 @@
ob4 = klass4(data)
self.assert_(ob < ob4, "cmp with different data")
+ def test_InstanceOnlyDescriptor(self):
+ from zope.app.rdb import InstanceOnlyDescriptor
+ inst = object() # could be anything
+ cls = object # could be any class
+ d = InstanceOnlyDescriptor()
+ self.assertRaises(AttributeError, d.__get__, inst, cls)
+ self.assertRaises(AttributeError, d.__get__, None, cls)
+ self.assertRaises(AttributeError, d.__delete__, inst)
+ d.__set__(inst, 23)
+ self.assertEquals(d.__get__(inst, cls), 23)
+ self.assertRaises(AttributeError, d.__get__, None, cls)
+ d = InstanceOnlyDescriptor(23)
+ self.assertEquals(d.__get__(inst, cls), 23)
+ d.__delete__(inst)
+ self.assertRaises(AttributeError, d.__get__, inst, cls)
+ self.assertRaises(AttributeError, d.__get__, None, cls)
+ self.assertRaises(AttributeError, d.__delete__, inst)
def test_suite():
=== Zope3/src/zope/app/rdb/tests/test_sqlcommand.py 1.4 => 1.4.18.1 ===
--- Zope3/src/zope/app/rdb/tests/test_sqlcommand.py:1.4 Tue Mar 11 11:11:15 2003
+++ Zope3/src/zope/app/rdb/tests/test_sqlcommand.py Sun Jun 22 10:23:21 2003
@@ -17,6 +17,8 @@
import unittest
+from zope.interface import implements
+
from zope.app.component import nextservice
from zope.app.interfaces.rdb import IConnectionService
from zope.app.interfaces.rdb import IZopeConnection
@@ -33,7 +35,7 @@
class CursorStub:
- __implements__ = IZopeCursor
+ implements(IZopeCursor)
description = (('id', 'int'),)
@@ -46,7 +48,7 @@
class ConnectionStub:
- __implements__ = IZopeConnection
+ implements(IZopeConnection)
def cursor(self):
return CursorStub()
@@ -54,7 +56,7 @@
class ConnectionServiceStub:
- __implements__ = IConnectionService, ISimpleService
+ implements(IConnectionService, ISimpleService)
def getConnection(self, name):
return ConnectionStub()