# Path: pyfusion/test/tests.py
# class PfTestBase(object):
#     """Base class for generated sql and non-sql test cases."""
#     pass


from pyfusion.test.tests import PfTestBase
        from pyfusion import orm
        from sqlalchemy import create_engine, MetaData
        from sqlalchemy.orm import scoped_session, sessionmaker
        from sqlalchemy.engine.base import Engine
        from sqlalchemy.orm.scoping import ScopedSession
        from pyfusion.orm import ORMManager
        from pyfusion.orm.utils import orm_register
        from sqlalchemy import MetaData
import pyfusion
    def test_orm(self):

class CheckORMManager(PfTestBase):
    def test_orm_manager(self):

        self.assertIsInstance(pyfusion.orm_manager, ORMManager)

        ## for testing, close sessoins and clear mappers before calling load_orm()
        if pyfusion.orm_manager.IS_ACTIVE:
            pyfusion.orm_manager.Session.close_all()
            pyfusion.orm_manager.clear_mappers()

        # check metadata, engine binding, etc
        pyfusion.orm_manager.setup_session()
        if pyfusion.orm_manager.IS_ACTIVE:
            self.assertIsInstance(pyfusion.orm_manager.engine, Engine)
            self.assertIsInstance(pyfusion.orm_manager.Session, ScopedSession)
            self.assertIsInstance(pyfusion.orm_manager.metadata, MetaData)
        
    def test_manager_reg(self):

        @orm_register()
        def test_orm_load(man):
            man.a = 1
            man.b = 2

        self.assertTrue(test_orm_load in pyfusion.orm_manager.func_list)

        ## for testing, close sessoins and clear mappers before calling load_orm()
        if pyfusion.orm_manager.IS_ACTIVE:

# Path: pyfusion/test/tests.py
# class PfTestBase(object):
#     """Base class for generated sql and non-sql test cases."""
#     pass


# Path: pyfusion/orm/tests.py
from pyfusion.test.tests import PfTestBase
        from pyfusion import orm
        from sqlalchemy import create_engine, MetaData
        from sqlalchemy.orm import scoped_session, sessionmaker
        from sqlalchemy.engine.base import Engine
        from sqlalchemy.orm.scoping import ScopedSession
        from pyfusion.orm import ORMManager
        from pyfusion.orm.utils import orm_register
        from sqlalchemy import MetaData
import pyfusion

    def test_orm(self):

class CheckORMManager(PfTestBase):
    def test_orm_manager(self):

        self.assertIsInstance(pyfusion.orm_manager, ORMManager)

        ## for testing, close sessoins and clear mappers before calling load_orm()
        if pyfusion.orm_manager.IS_ACTIVE:
            pyfusion.orm_manager.Session.close_all()
            pyfusion.orm_manager.clear_mappers()

        # check metadata, engine binding, etc
        pyfusion.orm_manager.setup_session()
        if pyfusion.orm_manager.IS_ACTIVE:
            self.assertIsInstance(pyfusion.orm_manager.engine, Engine)
            self.assertIsInstance(pyfusion.orm_manager.Session, ScopedSession)
            self.assertIsInstance(pyfusion.orm_manager.metadata, MetaData)
        
    def test_manager_reg(self):

        @orm_register()
        def test_orm_load(man):
            man.a = 1
            man.b = 2

        self.assertTrue(test_orm_load in pyfusion.orm_manager.func_list)

        ## for testing, close sessoins and clear mappers before calling load_orm()
        if pyfusion.orm_manager.IS_ACTIVE:

            pyfusion.orm_manager.Session.close_all()