Changeset - 18a754c2fc98
[Not reviewed]
0 1 0
Lance Edgar (lance) - 11 years ago 2013-11-14 22:36:27
lance@edbob.org
Fixed main `DataTestCase` configuration.
1 file changed with 4 insertions and 14 deletions:
0 comments (0 inline, 0 general)
tests/db/__init__.py
Show inline comments
 

	
 
import unittest
 

	
 
from sqlalchemy import create_engine
 

	
 
from edbob.db import Session, Base
 
from edbob.db.util import install_core_schema
 
from edbob.db.extensions import activate_extension
 

	
 

	
 
__all__ = ['DataTestCase']
 

	
 

	
 
# TODO: This is just awful...
 
engine = create_engine('sqlite://')
 
Session.configure(bind=engine)
 
install_core_schema(engine)
 
activate_extension('rattail', engine)
 

	
 

	
 
class DataTestCase(unittest.TestCase):
 

	
 
    def setUp(self):
 
        self.session = Session()
 
        for table in reversed(Base.metadata.sorted_tables):
 
            if not table.name.startswith('batch.'):
 
                self.session.execute(table.delete())
 
        self.session.commit()
 
        engine = create_engine('sqlite://')
 
        Base.metadata.create_all(bind=engine)
 
        self.session = Session(bind=engine)
 

	
 
    def tearDown(self):
 
        self.session.close()
0 comments (0 inline, 0 general)