[Zope-Checkins] CVS: Zope3/lib/python/ZODB/tests - testConnection.py:1.2 BasicStorage.py:1.19 ConflictResolution.py:1.8 Corruption.py:1.5 HistoryStorage.py:1.7 IteratorStorage.py:1.12 LocalStorage.py:1.3 MTStorage.py:1.3 MinPO.py:1.3 PackableStorage.py:1.13 PersistentStorage.py:1.2 ReadOnlyStorage.py:1.3 RevisionStorage.py:1.2 StorageTestBase.py:1.16 Synchronization.py:1.6 TransactionalUndoStorage.py:1.21 TransactionalUndoVersionStorage.py:1.7 VersionStorage.py:1.14 __init__.py:1.2 speed.py:1.4 testFileStorage.py:1.18 testMappingStorage.py:1.4 testTimeStamp.py:1.4 testTransaction.py:1.8 testUtils.py:1.2 testZODB.py:1.2 testfsIndex.py:1.5 testActivityMonitor.py:NONE testCache.py:NONE testDB.py:NONE testDemoStorage.py:NONE testPersistentList.py:NONE testPersistentMapping.py:NONE
Jim Fulton
jim@zope.com
Mon, 10 Jun 2002 19:28:51 -0400
Update of /cvs-repository/Zope3/lib/python/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv17445/lib/python/ZODB/tests
Modified Files:
BasicStorage.py ConflictResolution.py Corruption.py
HistoryStorage.py IteratorStorage.py LocalStorage.py
MTStorage.py MinPO.py PackableStorage.py PersistentStorage.py
ReadOnlyStorage.py RevisionStorage.py StorageTestBase.py
Synchronization.py TransactionalUndoStorage.py
TransactionalUndoVersionStorage.py VersionStorage.py
__init__.py speed.py testFileStorage.py testMappingStorage.py
testTimeStamp.py testTransaction.py testUtils.py testZODB.py
testfsIndex.py
Added Files:
testConnection.py
Removed Files:
testActivityMonitor.py testCache.py testDB.py
testDemoStorage.py testPersistentList.py
testPersistentMapping.py
Log Message:
Merged Zope-3x-branch into newly forked Zope3 CVS Tree.
=== Zope3/lib/python/ZODB/tests/testConnection.py 1.1 => 1.2 ===
+#
+# 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 unittest
+
+from Persistence import Persistent
+from Transaction.tests.abstestIDataManager import IDataManagerTests
+
+import ZODB
+from ZODB.MappingStorage import MappingStorage
+
+class P(Persistent):
+ pass
+
+class ConnectionTests(IDataManagerTests):
+
+ def setUp(self):
+ self.storage = MappingStorage()
+ self.db = ZODB.DB(self.storage)
+ self.datamgr = self.db.open()
+ self.obj = P()
+
+ def tearDown(self):
+ self.datamgr.close()
+ self.db.close()
+ self.storage.close()
+
+def test_suite():
+ return unittest.makeSuite(ConnectionTests)
=== Zope3/lib/python/ZODB/tests/BasicStorage.py 1.18 => 1.19 ===
+#
+# 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.
+#
+##############################################################################
"""Run the basic tests for a storage as described in the official storage API
The most complete and most out-of-date description of the interface is:
http://www.zope.org/Documentation/Developer/Models/ZODB/ZODB_Architecture_Storage_Interface_Info.html
All storages should be able to pass these tests.
+
+$Id$
"""
-from ZODB.Transaction import Transaction
+from Transaction import Transaction
from ZODB import POSException
from ZODB.tests.MinPO import MinPO
@@ -177,7 +192,7 @@
def checkTwoArgBegin(self):
# XXX how standard is three-argument tpc_begin()?
t = Transaction()
- tid = '\0\0\0\0\0psu'
+ tid = chr(42) * 8
self._storage.tpc_begin(t, tid)
oid = self._storage.new_oid()
data = zodb_pickle(MinPO(8))
=== Zope3/lib/python/ZODB/tests/ConflictResolution.py 1.7 => 1.8 ===
+#
+# 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.
+#
+##############################################################################
"""Tests for application-level conflict resolution."""
-from ZODB.Transaction import Transaction
+from Transaction import Transaction
from ZODB.POSException import ConflictError, UndoError
from Persistence import Persistent
=== Zope3/lib/python/ZODB/tests/Corruption.py 1.4 => 1.5 ===
+#
+# 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.
+#
+##############################################################################
"""Do some minimal tests of data corruption"""
import os
=== Zope3/lib/python/ZODB/tests/HistoryStorage.py 1.6 => 1.7 ===
+#
+# 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.
+#
+##############################################################################
"""Run the history() related tests for a storage.
Any storage that supports the history() method should be able to pass
=== Zope3/lib/python/ZODB/tests/IteratorStorage.py 1.11 => 1.12 ===
+#
+# 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.
+#
+##############################################################################
"""Run tests against the iterator() interface for storages.
Any storage that supports the iterator() method should be able to pass
=== Zope3/lib/python/ZODB/tests/LocalStorage.py 1.2 => 1.3 ===
+#
+# 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.
+#
+##############################################################################
class LocalStorage:
"""A single test that only make sense for local storages.
=== Zope3/lib/python/ZODB/tests/MTStorage.py 1.2 => 1.3 ===
+#
+# 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 random
import threading
import time
import ZODB
-from PersistentMapping import PersistentMapping
+from Persistence import PersistentMapping
from ZODB.tests.StorageTestBase \
import StorageTestBase, zodb_pickle, zodb_unpickle, handle_serials
@@ -55,12 +68,12 @@
root[name] = m
get_transaction().commit()
break
- except ConflictError:
+ except ConflictError, err:
get_transaction().abort()
for i in range(10):
try:
return root.get(name)
- except ConflictError:
+ except ConflictError, err:
get_transaction().abort()
class StorageClientThread(threading.Thread):
=== Zope3/lib/python/ZODB/tests/MinPO.py 1.2 => 1.3 ===
+#
+# 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.
+#
+##############################################################################
"""A minimal persistent object to use for tests"""
from Persistence import Persistent
=== Zope3/lib/python/ZODB/tests/PackableStorage.py 1.12 => 1.13 ===
+#
+# 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.
+#
+##############################################################################
"""Run some tests relevant for storages that support pack()."""
try:
@@ -106,11 +119,11 @@
try:
self._storage.load(ZERO, '')
except KeyError:
- import PersistentMapping
- from ZODB.Transaction import Transaction
+ from Persistence import PersistentMapping
+ from Transaction import Transaction
file = StringIO()
p = cPickle.Pickler(file, 1)
- p.dump((PersistentMapping.PersistentMapping, None))
+ p.dump((PersistentMapping, None))
p.dump({'_container': {}})
t=Transaction()
t.description='initial database creation'
=== Zope3/lib/python/ZODB/tests/PersistentStorage.py 1.1 => 1.2 ===
+#
+# 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.
+#
+##############################################################################
"""Test that a storage's values persist across open and close."""
class PersistentStorage:
=== Zope3/lib/python/ZODB/tests/ReadOnlyStorage.py 1.2 => 1.3 ===
+#
+# 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.
+#
+##############################################################################
from ZODB.POSException import ReadOnlyError
from ZODB.Transaction import Transaction
@@ -30,8 +43,6 @@
def checkWriteMethods(self):
self._make_readonly()
self.assertRaises(ReadOnlyError, self._storage.new_oid)
- self.assertRaises(ReadOnlyError, self._storage.undo,
- '\000' * 8)
t = Transaction()
self._storage.tpc_begin(t)
=== Zope3/lib/python/ZODB/tests/RevisionStorage.py 1.1 => 1.2 ===
+#
+# 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.
+#
+##############################################################################
"""Check loadSerial() on storages that support historical revisions."""
from ZODB.tests.MinPO import MinPO
=== Zope3/lib/python/ZODB/tests/StorageTestBase.py 1.15 => 1.16 ===
+#
+# 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.
+#
+##############################################################################
"""Provide a mixin base class for storage tests.
The StorageTestBase class provides basic setUp() and tearDown()
@@ -14,7 +27,7 @@
from cPickle import Pickler, Unpickler
from cStringIO import StringIO
-from ZODB.Transaction import Transaction
+from Transaction import Transaction
from ZODB.tests.MinPO import MinPO
=== Zope3/lib/python/ZODB/tests/Synchronization.py 1.5 => 1.6 ===
+#
+# 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.
+#
+##############################################################################
"""Test the storage's implemenetation of the storage synchronization spec.
The Synchronization spec
@@ -49,7 +62,7 @@
"""
-from ZODB.Transaction import Transaction
+from Transaction import Transaction
from ZODB.POSException import StorageTransactionError
VERSION = "testversion"
=== Zope3/lib/python/ZODB/tests/TransactionalUndoStorage.py 1.20 => 1.21 ===
+#
+# 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.
+#
+##############################################################################
"""Check transactionalUndo().
Any storage that supports transactionalUndo() must pass these tests.
"""
-import time
import types
from ZODB import POSException
from ZODB.Transaction import Transaction
-from ZODB.referencesf import referencesf
-from ZODB.utils import u64
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
ZERO = '\0'*8
+
class TransactionalUndoStorage:
def _transaction_begin(self):
@@ -423,41 +434,3 @@
self._storage.transactionalUndo,
tid, t)
self._storage.tpc_abort(t)
-
- def checkTransactionalUndoAfterPack(self):
- eq = self.assertEqual
- # Add a few object revisions
- oid = self._storage.new_oid()
- revid1 = self._dostore(oid, data=MinPO(51))
- # For the pack(), we need a timestamp greater than revid1's timestamp.
- # The semantics of pack()'s `t' argument is that all non-current
- # revisions with an earlier timestamp will be packed away. If they
- # were equal (because the Windows clock resolution is too coarse),
- # then we won't pack away the first revision.
- now = packtime = time.time()
- while packtime <= now:
- packtime = time.time()
- revid2 = self._dostore(oid, revid=revid1, data=MinPO(52))
- revid3 = self._dostore(oid, revid=revid2, data=MinPO(53))
- # Now get the undo log
- info = self._storage.undoInfo()
- eq(len(info), 3)
- tid = info[0]['id']
- # Now pack just the initial revision of the object. We need the
- # second revision otherwise we won't be able to undo the third
- # revision!
- self._storage.pack(packtime, referencesf)
- # Make some basic assertions about the undo information now
- info2 = self._storage.undoInfo()
- eq(len(info2), 2)
- # And now attempt to undo the last transaction
- t = Transaction()
- self._storage.tpc_begin(t)
- oids = self._storage.transactionalUndo(tid, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
- eq(len(oids), 1)
- eq(oids[0], oid)
- data, revid = self._storage.load(oid, '')
- # The object must now be at the second state
- eq(zodb_unpickle(data), MinPO(52))
=== Zope3/lib/python/ZODB/tests/TransactionalUndoVersionStorage.py 1.6 => 1.7 ===
-
+##############################################################################
+#
+# 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.
+#
+##############################################################################
# Check interactions between transactionalUndo() and versions. Any storage
# that supports both transactionalUndo() and versions must pass these tests.
-import time
-
from ZODB import POSException
-from ZODB.referencesf import referencesf
from ZODB.Transaction import Transaction
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle
@@ -100,115 +108,3 @@
assert zodb_unpickle(data) == MinPO(92)
data, revid = self._storage.load(oid, '')
assert zodb_unpickle(data) == MinPO(91)
-
- def checkUndoCommitVersion(self):
- def load_value(oid, version=''):
- data, revid = self._storage.load(oid, version)
- return zodb_unpickle(data).value
-
- # create a bunch of packable transactions
- oid = self._storage.new_oid()
- revid = '\000' * 8
- for i in range(4):
- revid = self._dostore(oid, revid, description='packable%d' % i)
- pt = time.time()
- time.sleep(1)
-
- oid1 = self._storage.new_oid()
- version = 'version'
- revid1 = self._dostore(oid1, data=MinPO(0), description='create1')
- revid2 = self._dostore(oid1, data=MinPO(1), revid=revid1,
- version=version, description='version1')
- revid3 = self._dostore(oid1, data=MinPO(2), revid=revid2,
- version=version, description='version2')
- self._dostore(description='create2')
-
- t = Transaction()
- t.description = 'commit version'
- self._storage.tpc_begin(t)
- self._storage.commitVersion(version, '', t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
-
- info = self._storage.undoInfo()
- t_id = info[0]['id']
-
- self.assertEqual(load_value(oid1), 2)
- self.assertEqual(load_value(oid1, version), 2)
-
- self._storage.pack(pt, referencesf)
-
- t = Transaction()
- t.description = 'undo commit version'
- self._storage.tpc_begin(t)
- self._storage.transactionalUndo(t_id, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
-
- self.assertEqual(load_value(oid1), 0)
- self.assertEqual(load_value(oid1, version), 2)
-
- def checkUndoAbortVersion(self):
- def load_value(oid, version=''):
- data, revid = self._storage.load(oid, version)
- return zodb_unpickle(data).value
-
- # create a bunch of packable transactions
- oid = self._storage.new_oid()
- revid = '\000' * 8
- for i in range(3):
- revid = self._dostore(oid, revid, description='packable%d' % i)
- pt = time.time()
- time.sleep(1)
-
- oid1 = self._storage.new_oid()
- version = 'version'
- revid1 = self._dostore(oid1, data=MinPO(0), description='create1')
- revid2 = self._dostore(oid1, data=MinPO(1), revid=revid1,
- version=version, description='version1')
- revid3 = self._dostore(oid1, data=MinPO(2), revid=revid2,
- version=version, description='version2')
- self._dostore(description='create2')
-
- t = Transaction()
- t.description = 'abort version'
- self._storage.tpc_begin(t)
- self._storage.abortVersion(version, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
-
- info = self._storage.undoInfo()
- t_id = info[0]['id']
-
- self.assertEqual(load_value(oid1), 0)
- # after abort, we should see non-version data
- self.assertEqual(load_value(oid1, version), 0)
-
- t = Transaction()
- t.description = 'undo abort version'
- self._storage.tpc_begin(t)
- self._storage.transactionalUndo(t_id, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
-
- self.assertEqual(load_value(oid1), 0)
- # t undo will re-create the version
- self.assertEqual(load_value(oid1, version), 2)
-
- info = self._storage.undoInfo()
- t_id = info[0]['id']
-
- self._storage.pack(pt, referencesf)
-
- t = Transaction()
- t.description = 'undo undo'
- self._storage.tpc_begin(t)
- self._storage.transactionalUndo(t_id, t)
- self._storage.tpc_vote(t)
- self._storage.tpc_finish(t)
-
- # undo of undo will put as back where we started
- self.assertEqual(load_value(oid1), 0)
- # after abort, we should see non-version data
- self.assertEqual(load_value(oid1, version), 0)
-
=== Zope3/lib/python/ZODB/tests/VersionStorage.py 1.13 => 1.14 ===
+#
+# 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.
+#
+##############################################################################
"""Run the version related tests for a storage.
Any storage that supports versions should be able to pass all these tests.
=== Zope3/lib/python/ZODB/tests/__init__.py 1.1 => 1.2 ===
+#
+# 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.
+#
+##############################################################################
# Having this makes debugging better.
=== Zope3/lib/python/ZODB/tests/speed.py 1.3 => 1.4 ===
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
+# FOR A PARTICULAR PURPOSE.
#
##############################################################################
usage="""Test speed of a ZODB storage
=== Zope3/lib/python/ZODB/tests/testFileStorage.py 1.17 => 1.18 ===
+#
+# 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.
+#
+##############################################################################
from __future__ import nested_scopes
import ZODB.FileStorage
import sys, os, unittest
import errno
-from ZODB.Transaction import Transaction
-from ZODB import POSException
+from Transaction import Transaction
from ZODB.tests import StorageTestBase, BasicStorage, \
TransactionalUndoStorage, VersionStorage, \
@@ -48,21 +60,6 @@
path = 'FileStorageTests.fs' + ext
if os.path.exists(path):
os.remove(path)
-
- def checkLongMetadata(self):
- s = "X" * 75000
- try:
- self._dostore(user=s)
- except POSException.StorageError:
- pass
- else:
- self.fail("expect long user field to raise error")
- try:
- self._dostore(description=s)
- except POSException.StorageError:
- pass
- else:
- self.fail("expect long user field to raise error")
class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase,
=== Zope3/lib/python/ZODB/tests/testMappingStorage.py 1.3 => 1.4 ===
+#
+# 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 ZODB.MappingStorage
import os, unittest
=== Zope3/lib/python/ZODB/tests/testTimeStamp.py 1.3 => 1.4 ===
+#
+# 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.
+#
+##############################################################################
"""Test the TimeStamp utility type"""
import time
@@ -28,7 +41,7 @@
self.assertEquals(dy, t[2])
def checkFullTimeStamp(self):
- t = time.gmtime(time.time())
+ t = time.gmtime()
ts = TimeStamp(*t[:6])
# XXX floating point comparison
@@ -43,9 +56,9 @@
self.assert_(abs(ts.second() - t[5]) < EPSILON)
def checkRawTimestamp(self):
- t = time.gmtime(time.time())
+ t = time.gmtime()
ts1 = TimeStamp(*t[:6])
- ts2 = TimeStamp(`ts1`)
+ ts2 = TimeStamp(ts1.raw())
self.assertEquals(ts1, ts2)
self.assertEquals(ts1.timeTime(), ts2.timeTime())
@@ -57,7 +70,7 @@
self.assert_(abs(ts1.second() - ts2.second()) < EPSILON)
def checkDictKey(self):
- t = time.gmtime(time.time())
+ t = time.gmtime()
ts1 = TimeStamp(*t[:6])
ts2 = TimeStamp(2000, *t[1:6])
@@ -75,47 +88,12 @@
def checkLaterThan(self):
# XXX what does laterThan() do?
- t = time.gmtime(time.time())
+ t = time.gmtime()
ts = TimeStamp(*t[:6])
ts2 = ts.laterThan(ts)
self.assert_(ts2 > ts)
# XXX should test for bogus inputs to TimeStamp constructor
-
- def checkTimeStamp(self):
- # Alternate test suite
- t = TimeStamp(2002, 1, 23, 10, 48, 5) # GMT
- self.assertEquals(str(t), '2002-01-23 10:48:05.000000')
- self.assertEquals(repr(t), '\x03B9H\x15UUU')
- self.assertEquals(TimeStamp('\x03B9H\x15UUU'), t)
- self.assertEquals(t.year(), 2002)
- self.assertEquals(t.month(), 1)
- self.assertEquals(t.day(), 23)
- self.assertEquals(t.hour(), 10)
- self.assertEquals(t.minute(), 48)
- self.assertEquals(round(t.second()), 5)
- self.assertEquals(t.second(), t.seconds()) # Alias
- self.assertEquals(t.timeTime(), 1011782885)
- t1 = TimeStamp(2002, 1, 23, 10, 48, 10)
- self.assertEquals(str(t1), '2002-01-23 10:48:10.000000')
- self.assert_(t == t)
- self.assert_(t != t1)
- self.assert_(t < t1)
- self.assert_(t <= t1)
- self.assert_(t1 >= t)
- self.assert_(t1 > t)
- self.failIf(t == t1)
- self.failIf(t != t)
- self.failIf(t > t1)
- self.failIf(t >= t1)
- self.failIf(t1 < t)
- self.failIf(t1 <= t)
- self.assertEquals(cmp(t, t), 0)
- self.assertEquals(cmp(t, t1), -1)
- self.assertEquals(cmp(t1, t), 1)
- self.assertEquals(t1.laterThan(t), t1)
- self.assert_(t.laterThan(t1) > t1)
- self.assertEquals(TimeStamp(2002,1,23), TimeStamp(2002,1,23,0,0,0))
def test_suite():
return unittest.makeSuite(TimeStampTests, 'check')
=== Zope3/lib/python/ZODB/tests/testTransaction.py 1.7 => 1.8 === (612/712 lines abridged)
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
+# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""High-level tests of the transaction interface"""
-"""
-Revision information:
-$Id$
-"""
-
-"""
-
-I wrote these unittests to investigate some odd transaction
-behavior when doing unittests of integrating non sub transaction
-aware objects, and to insure proper txn behavior. these
-tests test the transaction system independent of the rest of the
-zodb.
-
-you can see the method calls to a jar by passing the
-keyword arg tracing to the modify method of a dataobject.
-the value of the arg is a prefix used for tracing print calls
-to that objects jar.
-
-the number of times a jar method was called can be inspected
-by looking at an attribute of the jar that is the method
-name prefixed with a c (count/check).
-
-i've included some tracing examples for tests that i thought
-were illuminating as doc strings below.
-
-TODO
-
- add in tests for objects which are modified multiple times,
- for example an object that gets modified in multiple sub txns.
-
-"""
-
-from types import TupleType
+import os
+import tempfile
import unittest
-from ZODB import Transaction
+import ZODB
+from ZODB.DB import DB
+from ZODB.FileStorage import FileStorage
+from ZODB.tests.MinPO import MinPO
[-=- -=- -=- 612 lines omitted -=- -=- -=-]
-
- def abort(self, *args):
- self.check('abort')
- self.cabort += 1
-
- def commit(self, *args):
- self.check('commit')
- self.ccommit += 1
-
- def tpc_begin(self, txn, sub=0):
- self.check('tpc_begin')
- self.ctpc_begin += 1
-
- def tpc_vote(self, *args):
- self.check('tpc_vote')
- self.ctpc_vote += 1
-
- def tpc_abort(self, *args):
- self.check('tpc_abort')
- self.ctpc_abort += 1
-
- def tpc_finish(self, *args):
- self.check('tpc_finish')
- self.ctpc_finish += 1
-
-class SubTransactionJar(BasicJar):
-
- def abort_sub(self, txn):
- self.check('abort_sub')
- self.cabort_sub = 1
-
- def commit_sub(self, txn):
- self.check('commit_sub')
- self.ccommit_sub = 1
-
-class NoSubTransactionJar(BasicJar): pass
-
def test_suite():
+ return unittest.makeSuite(AllTests, 'check')
- return unittest.makeSuite(TransactionTests)
+def main():
+ tests = test_suite()
+ runner = unittest.TextTestRunner()
+ runner.run(tests)
-if __name__ == '__main__':
- unittest.TextTestRunner().run(test_suite())
+if __name__ == "__main__":
+ main()
=== Zope3/lib/python/ZODB/tests/testUtils.py 1.1 => 1.2 ===
+#
+# 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.
+#
+##############################################################################
"""Test the routines to convert between long and 64-bit strings"""
import random
=== Zope3/lib/python/ZODB/tests/testZODB.py 1.1 => 1.2 ===
+#
+# 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 sys, os
-sys.path[0:0] = [os.curdir, os.path.join(os.pardir, os.pardir)]
-
import ZODB
import ZODB.FileStorage
-from ZODB.PersistentMapping import PersistentMapping
+from Persistence import PersistentMapping
import unittest
class ExportImportTests:
- def checkDuplicate(self, abort_it=0, dup_name='test_duplicate'):
- get_transaction().begin()
- get_transaction().note('duplication')
- # Duplicate the 'test' object.
+
+ def duplicate(self, abort_it, dup_name):
conn = self._db.open()
try:
root = conn.root()
ob = root['test']
- assert len(ob) > 10, 'Insufficient test data'
+ self.assert_(len(ob) > 10, 'Insufficient test data')
try:
import tempfile
f = tempfile.TemporaryFile()
ob._p_jar.exportFile(ob._p_oid, f)
- assert f.tell() > 0, 'Did not export correctly'
+ self.assert_(f.tell() > 0, 'Did not export correctly')
f.seek(0)
new_ob = ob._p_jar.importFile(f)
root[dup_name] = new_ob
@@ -35,6 +44,8 @@
raise
finally:
conn.close()
+
+ def verify(self, abort_it, dup_name):
get_transaction().begin()
# Verify the duplicate.
conn = self._db.open()
@@ -70,16 +81,23 @@
get_transaction().commit()
finally:
conn.close()
+
+ def checkDuplicate(self, abort_it=0, dup_name='test_duplicate'):
+ get_transaction().begin()
+ get_transaction().note('duplication')
+ self.duplicate(abort_it, dup_name)
+ self.verify(abort_it, dup_name)
def checkDuplicateAborted(self):
self.checkDuplicate(abort_it=1, dup_name='test_duplicate_aborted')
-
class ZODBTests(unittest.TestCase, ExportImportTests):
def setUp(self):
- try: os.remove('ZODBTests.fs')
- except: pass
+ try:
+ os.remove('ZODBTests.fs')
+ except:
+ pass
self._storage = ZODB.FileStorage.FileStorage(
'ZODBTests.fs', create=1)
self._db = ZODB.DB(self._storage)
@@ -95,7 +113,10 @@
def tearDown(self):
self._storage.close()
- os.remove('ZODBTests.fs')
+ for ext in '', '.old', '.tmp', '.lock', '.index':
+ path = 'ZODBTests.fs' + ext
+ if os.path.exists(path):
+ os.remove(path)
def test_suite():
return unittest.makeSuite(ZODBTests, 'check')
@@ -104,13 +125,6 @@
alltests=test_suite()
runner = unittest.TextTestRunner()
runner.run(alltests)
-
-def debug():
- test_suite().debug()
-
-def pdebug():
- import pdb
- pdb.run('debug()')
if __name__=='__main__':
if len(sys.argv) > 1:
=== Zope3/lib/python/ZODB/tests/testfsIndex.py 1.4 => 1.5 ===
+#
+# 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 unittest, sys
from ZODB.fsIndex import fsIndex
=== Removed File Zope3/lib/python/ZODB/tests/testActivityMonitor.py ===
=== Removed File Zope3/lib/python/ZODB/tests/testCache.py ===
=== Removed File Zope3/lib/python/ZODB/tests/testDB.py ===
=== Removed File Zope3/lib/python/ZODB/tests/testDemoStorage.py ===
=== Removed File Zope3/lib/python/ZODB/tests/testPersistentList.py ===
=== Removed File Zope3/lib/python/ZODB/tests/testPersistentMapping.py ===