# Path: gengine/metadata.py
# def init_session(override_session=None, replace=False):
#     global DBSession
#     if DBSession.target and not replace:
#         return
#     if override_session:
#         DBSession.target = override_session
#     else:
#         DBSession.target = scoped_session(get_sessionmaker())
# 
# def get_sessionmaker(bind=None):
#     return sessionmaker(
#         extension=ZopeTransactionExtension(),
#         class_=MySession,
#         bind=bind
#     )
# 
# Path: gengine/app/tests/db.py
# def setupDB():
# def unsetupDB():


import shutil
import unittest
import os
from sqlalchemy.engine import create_engine
from sqlalchemy.sql.schema import Table
from sqlalchemy.orm.scoping import scoped_session
from gengine.metadata import init_session, get_sessionmaker
from gengine.app.tests import db as testDB
        from gengine.app.cache import clear_all_caches
        from gengine.metadata import Base
        from alembic.config import Config
        from alembic import command
        from gengine.app import model

class BaseDBTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        if cls is BaseDBTest:
            raise unittest.SkipTest("Skip BaseTest tests, it's a base class")
        super(BaseDBTest, cls).setUpClass()

    def setUp(self):
        clear_all_caches()

        if os.path.exists("/tmp/test_pgdata"):
            shutil.rmtree("/tmp/test_pgdata")


# Path: gengine/metadata.py
# def init_session(override_session=None, replace=False):
#     global DBSession
#     if DBSession.target and not replace:
#         return
#     if override_session:
#         DBSession.target = override_session
#     else:
#         DBSession.target = scoped_session(get_sessionmaker())
# 
# def get_sessionmaker(bind=None):
#     return sessionmaker(
#         extension=ZopeTransactionExtension(),
#         class_=MySession,
#         bind=bind
#     )
# 
# Path: gengine/app/tests/db.py
# def setupDB():
# def unsetupDB():


# Path: gengine/app/tests/base.py
import shutil
import unittest
import os
from sqlalchemy.engine import create_engine
from sqlalchemy.sql.schema import Table
from sqlalchemy.orm.scoping import scoped_session
from gengine.metadata import init_session, get_sessionmaker
from gengine.app.tests import db as testDB
        from gengine.app.cache import clear_all_caches
        from gengine.metadata import Base
        from alembic.config import Config
        from alembic import command
        from gengine.app import model


class BaseDBTest(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        if cls is BaseDBTest:
            raise unittest.SkipTest("Skip BaseTest tests, it's a base class")
        super(BaseDBTest, cls).setUpClass()

    def setUp(self):
        clear_all_caches()

        if os.path.exists("/tmp/test_pgdata"):
            shutil.rmtree("/tmp/test_pgdata")


        self.db = testDB.db()