Ejemplo n.º 1
0
 def setup(self):
     """
     Run once before every test. Setup the test database.
     """
     self.app = create_app(TEST_SETTINGS)
     self.client = self.app.test_client()
     with self.app.test_request_context():
         db.create_all()
         db.session.commit()
Ejemplo n.º 2
0
def apply_driver_hacks(self, app, info, options):
    if info.drivername == 'sqlite' and info.database in (None, '', ':memory:'):
        options['poolclass'] = StaticPool
        options['connect_args'] = {'check_same_thread': False}
        try:
            del options['pool_size']
        except KeyError:
            pass
    _apply_driver_hacks(self, app, info, options)
SQLAlchemy.apply_driver_hacks = apply_driver_hacks


from sqlalchemy.engine.url import make_url
from montana import create_app, db

app = create_app()

# If we have an in-memory database, setup the schema first.
info = make_url(app.config['SQLALCHEMY_DATABASE_URI'])
if info.drivername == 'sqlite' and info.database in (None, '', ':memory:'):
    print 'Setting up in-memory database'
    with app.test_request_context():
        db.create_all()


if __name__ == '__main__':
    import glob
    import sys
    from montana import models

    if '--load-fixtures' in sys.argv: