# Path: suma/core/models/meta/base.py
# class Base(object):
#     @declared_attr
#     def __tablename__(cls):
#         return _camel_to_snake(cls.__name__)
# 
#     __table_args__ = {'schema': 'suma'}
# 
#     id = Column(Integer, primary_key=True)
# 
# def create_dbsession(engine):
#     dbsession = scoped_session(sessionmaker())
#     dbsession.configure(bind=engine)
#     Base.metadata.bind = engine
#     return dbsession


import pytest
import zope.sqlalchemy
import types
from sqlalchemy import create_engine
from suma.core.models.meta import create_dbsession, Base
from pyramid import testing
from pyramid_services import find_service
from zope.interface.adapter import AdapterRegistry
    from transaction import abort


@pytest.fixture(scope='session')
def db(request):
    """Session-scoped sqlalchemy database connection"""
    engine = create_engine('postgresql://suma@/suma_test')
    dbsession = create_dbsession(engine)
    zope.sqlalchemy.register(dbsession)
    # we drop before to be sure we didn't leave the previous state unclean
    Base.metadata.drop_all()

# Path: suma/core/models/meta/base.py
# class Base(object):
#     @declared_attr
#     def __tablename__(cls):
#         return _camel_to_snake(cls.__name__)
# 
#     __table_args__ = {'schema': 'suma'}
# 
#     id = Column(Integer, primary_key=True)
# 
# def create_dbsession(engine):
#     dbsession = scoped_session(sessionmaker())
#     dbsession.configure(bind=engine)
#     Base.metadata.bind = engine
#     return dbsession


# Path: tests/conftest.py
import pytest
import zope.sqlalchemy
import types
from sqlalchemy import create_engine
from suma.core.models.meta import create_dbsession, Base
from pyramid import testing
from pyramid_services import find_service
from zope.interface.adapter import AdapterRegistry
    from transaction import abort



@pytest.fixture(scope='session')
def db(request):
    """Session-scoped sqlalchemy database connection"""
    engine = create_engine('postgresql://suma@/suma_test')
    dbsession = create_dbsession(engine)
    zope.sqlalchemy.register(dbsession)
    # we drop before to be sure we didn't leave the previous state unclean
    Base.metadata.drop_all()

    Base.metadata.create_all()