[Zodb-checkins] CVS: ZODB3/ZODB/tests - testConfig.py:1.1.2.1
Jeremy Hylton
jeremy@zope.com
Thu, 2 Jan 2003 17:30:54 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv27904/tests
Added Files:
Tag: zconfg-schema-devel-branch
testConfig.py
Log Message:
Some preliminary code to create databases from config files
=== Added File ZODB3/ZODB/tests/testConfig.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.
#
##############################################################################
import os
import tempfile
import unittest
from ZODB.POSException import ReadOnlyError
import ZODB.config
import ZODB.tests
class ZODBConfigTest(unittest.TestCase):
def _test(self, s):
db = ZODB.config.databaseFromString(s)
# Do something with the database to make sure it works
cn = db.open()
rt = cn.root()
rt["test"] = 1
get_transaction().commit()
db.close()
def test_map_config1(self):
self._test("<mappingstorage boo/>")
def test_map_config2(self):
self._test(
"""<mappingstorage boo/>
cache_size 1000
""")
def test_file_config1(self):
path = tempfile.mktemp()
self._test(
"""<filestorage boo>
path %s
</filestorage>
""" % path)
os.unlink(path)
def test_file_config2(self):
path = tempfile.mktemp()
cfg = \
"""<filestorage boo>
path %s
create false
read_only true
</filestorage>
""" % path
self.assertRaises(ReadOnlyError, self._test, cfg)
def test_suite():
return unittest.makeSuite(ZODBConfigTest)