Commit 2bdeec1b authored by Barry Warsaw's avatar Barry Warsaw

Reworked to use the ZODBTestBase class and the new mixin style of

creating test classes.
parent 18f51531
# Test creation of a brand new database, and insertion of root objects.
import unittest
import test_create
from ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping
class BaseInsertMixin:
class InsertMixin:
def checkIsEmpty(self):
assert not self._root.has_key('names')
def checkNewInserts(self):
from Persistence import PersistentMapping
self._root['names'] = names = PersistentMapping()
names['Warsaw'] = 'Barry'
names['Hylton'] = 'Jeremy'
......@@ -19,21 +19,21 @@ class BaseInsertMixin:
class FullNewInsertsTest(test_create.FullBaseFramework, BaseInsertMixin):
pass
class FullNewInsertsTest(ZODBTestBase, InsertMixin):
import Full
ConcreteStorage = Full.Full
class MinimalNewInsertsTest(test_create.MinimalBaseFramework, BaseInsertMixin):
pass
class MinimalNewInsertsTest(ZODBTestBase, InsertMixin):
import Minimal
ConcreteStorage = Minimal.Minimal
def suite():
suite = unittest.TestSuite()
suite.addTest(MinimalNewInsertsTest('checkIsEmpty'))
suite.addTest(MinimalNewInsertsTest('checkNewInserts'))
suite.addTest(FullNewInsertsTest('checkIsEmpty'))
suite.addTest(FullNewInsertsTest('checkNewInserts'))
suite.addTest(unittest.makeSuite(MinimalNewInsertsTest, 'check'))
suite.addTest(unittest.makeSuite(FullNewInsertsTest, 'check'))
return suite
......
......@@ -2,18 +2,16 @@
# storages, like transaction aborts and commits, changing objects, etc.
# Doesn't test undo, versions, or packing.
import os
import errno
import time
import unittest
import test_create
from ZODBTestBase import ZODBTestBase
from Persistence import PersistentMapping
class CommitAndRead(test_create.BaseFramework):
class CommitAndRead:
def checkCommit(self):
from Persistence import PersistentMapping
assert not self._root
names = self._root['names'] = PersistentMapping()
names['Warsaw'] = 'Barry'
......@@ -52,12 +50,12 @@ class CommitAndRead(test_create.BaseFramework):
class MinimalCommitAndRead(CommitAndRead):
class MinimalCommitAndRead(ZODBTestBase, CommitAndRead):
import Minimal
ConcreteStorage = Minimal.Minimal
class FullCommitAndRead(CommitAndRead):
class FullCommitAndRead(ZODBTestBase, CommitAndRead):
import Full
ConcreteStorage = Full.Full
......@@ -65,20 +63,8 @@ class FullCommitAndRead(CommitAndRead):
def suite():
suite = unittest.TestSuite()
# On the Minimal storage
suite.addTest(MinimalCommitAndRead('checkCommit'))
suite.addTest(MinimalCommitAndRead('checkReadAfterCommit'))
suite.addTest(MinimalCommitAndRead('checkAbortAfterRead'))
suite.addTest(MinimalCommitAndRead('checkReadAfterCommit'))
for i in range(5):
suite.addTest(MinimalCommitAndRead('checkChangingCommits'))
# On the Full storage
suite.addTest(FullCommitAndRead('checkCommit'))
suite.addTest(FullCommitAndRead('checkReadAfterCommit'))
suite.addTest(FullCommitAndRead('checkAbortAfterRead'))
suite.addTest(FullCommitAndRead('checkReadAfterCommit'))
for i in range(5):
suite.addTest(FullCommitAndRead('checkChangingCommits'))
suite.addTest(unittest.makeSuite(MinimalCommitAndRead, 'check'))
suite.addTest(unittest.makeSuite(FullCommitAndRead, 'check'))
return suite
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment