[Zope3-checkins] CVS: zopeproducts/sybaseda/tests - __init__.py:1.1
test_adapter.py:1.1
runyaga
runyaga at thisbox.com
Mon Aug 11 04:23:34 EDT 2003
Update of /cvs-repository/zopeproducts/sybaseda/tests
In directory cvs.zope.org:/tmp/cvs-serv21039/tests
Added Files:
__init__.py test_adapter.py
Log Message:
created new module, sybaseda to be consistent with zope3 naming
removed browser module from sybaseDA and moved everything into
sybaseda module. have simple test_adatper.py but will write
unit tests for dates when we start using them on our application.
can someone get rid of the old 'sybaseDA' module?
=== Added File zopeproducts/sybaseda/tests/__init__.py ===
##############################################################################
#
# Copyright (c) 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.
#
##############################################################################
"""Unit tests for Sybase Database Adapter"""
=== Added File zopeproducts/sybaseda/tests/test_adapter.py ===
##############################################################################
#
# 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.
#
##############################################################################
"""Unit tests for SybaseDA."""
from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.rdb import parseDSN
import Sybase
from datetime import tzinfo, timedelta
class SybaseStub:
__shared_state = {} # 'Borg' design pattern
def __init__(self):
self.__dict__ = self.__shared_state
self.types = {}
def connect(self, host, user, passwd, database=None):
opts = {'host':host,
'user':user,
'password':passwd,
'dbname':database}
conn_str='dbi://%(user)s:%(password)s@%(host)s:/%(dbname)s' % opts
self.last_connection_string = conn_str
def new_type(self, values, name, converter):
return Stub(name=name, values=values)
class TestSybaseAdapter(TestCase):
def setUp(self):
import zopeproducts.sybaseda.adapter as adapter
self.real_sybase = adapter.Sybase
adapter.Sybase = self.sybase_stub = SybaseStub()
def tearDown(self):
import zopeproducts.sybaseda.adapter as adapter
adapter.Sybase = self.real_sybase
def test_connection_factory(self):
from zopeproducts.sybaseda.adapter import SybaseAdapter
a = SybaseAdapter('dbi://username:password@host:/dbname')
c = a._connection_factory()
args = parseDSN(self.sybase_stub.last_connection_string)
self.assertEquals(args, {'username':'username',
'password':'password',
'dbname':'dbname',
'host':'host',
'port':'',
'parameters': {} } )
def test_suite():
return TestSuite((
makeSuite(TestSybaseAdapter),
))
if __name__=='__main__':
main(defaultTest='test_suite')
More information about the Zope3-Checkins
mailing list