Commit c5e32fb1 authored by Barry Warsaw's avatar Barry Warsaw

Factor out commonality between the Minimal and Full tests.

parent 715a9173
......@@ -6,16 +6,15 @@ import unittest
class MinimalBaseFramework(unittest.TestCase):
class BaseFramework(unittest.TestCase):
def setUp(self):
import Minimal
from ZODB import DB
self._dbhome = 'test-db'
os.mkdir(self._dbhome)
try:
self._storage = Minimal.Minimal(self._dbhome)
self._storage = self.ConcreteStorage(self._dbhome)
self._db = DB(self._storage)
self._conn = self._db.open()
self._root = self._conn.root()
......@@ -27,44 +26,28 @@ class MinimalBaseFramework(unittest.TestCase):
for file in os.listdir(self._dbhome):
os.unlink(os.path.join(self._dbhome, file))
os.removedirs(self._dbhome)
def checkDBHomeExists(self):
assert os.path.isdir(self._dbhome)
class FullBaseFramework(unittest.TestCase):
def setUp(self):
import Full
from ZODB import DB
self._dbhome = 'test-db'
os.mkdir(self._dbhome)
try:
self._storage = Full.Full(self._dbhome)
self._db = DB(self._storage)
self._conn = self._db.open()
self._root = self._conn.root()
except:
self.tearDown()
raise
def tearDown(self):
for file in os.listdir(self._dbhome):
os.unlink(os.path.join(self._dbhome, file))
os.removedirs(self._dbhome)
class MinimalBaseFramework(BaseFramework):
import Minimal
ConcreteStorage = Minimal.Minimal
class MinimalDBHomeTest(MinimalBaseFramework):
def checkDBHomeExists(self):
"""Minimal: Database creation w/ explicit db_home"""
assert os.path.isdir(self._dbhome)
pass
class FullBaseFramework(BaseFramework):
import Full
ConcreteStorage = Full.Full
class FullDBHomeTest(FullBaseFramework):
def checkDBHomeExists(self):
"""Full: Database creation w/ explicit db_home"""
assert os.path.isdir(self._dbhome)
pass
......
......@@ -5,13 +5,11 @@ import test_create
class FullNewInsertsTest(test_create.FullBaseFramework):
class BaseInsertMixin:
def checkIsEmpty(self):
"""Full: Newly created database should be empty"""
assert not self._root.has_key('names')
def checkNewInserts(self):
"""Full: Commiting on a newly created database"""
from Persistence import PersistentMapping
self._root['names'] = names = PersistentMapping()
......@@ -21,19 +19,12 @@ class FullNewInsertsTest(test_create.FullBaseFramework):
class MinimalNewInsertsTest(test_create.MinimalBaseFramework):
def checkIsEmpty(self):
"""Minimal: Newly created database is empty"""
assert not self._root.has_key('names')
class FullNewInsertsTest(test_create.FullBaseFramework, BaseInsertMixin):
pass
def checkNewInserts(self):
"""Minimal: Committing on a newly created database"""
from Persistence import PersistentMapping
self._root['names'] = names = PersistentMapping()
names['Warsaw'] = 'Barry'
names['Hylton'] = 'Jeremy'
get_transaction().commit()
class MinimalNewInsertsTest(test_create.MinimalBaseFramework, BaseInsertMixin):
pass
......
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