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