Пример #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()
Пример #2
0
            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:
        with app.test_request_context():
            for fixture in sorted(glob.iglob('fixtures/*.fixture.json')):
                print 'Loading fixture: %s' % fixture
                models.load_fixture(open(fixture))

    if not app.config['API_KEY']:
        print 'Warning: no API key set!'