Пример #1
0
def pytest_configure(config):
    from wonder.romeo import create_app, db
    app = create_app()
    app.test_client_class = FlaskRestClient
    app.app_context().push()

    if 'TEST_DATABASE_URL' in app.config:
        testdb_uri = app.config['SQLALCHEMY_DATABASE_URI'] = app.config['TEST_DATABASE_URL']
    else:
        testdb_base_url = app.config.get('TEST_DATABASE_BASE_URL', 'postgresql:///')
        testdb = datetime.now().strftime('test_%Y%m%d%H%M%S')
        testdb_uri = app.config['SQLALCHEMY_DATABASE_URI'] = testdb_base_url + testdb
    try:
        db.create_all()
    except OperationalError as e:
        if 'does not exist' in e.message:
            config._testdb_uri = testdb_uri
            _create_db(testdb_uri)
            db.create_all()

    from .fixtures import loaddata
    loaddata()
Пример #2
0
import sys
import os
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
sys.path.insert(0, os.getcwd())
from wonder.romeo import db, create_app

app = create_app()

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = db.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline():