def setUp(self): self.ctx = app.test_request_context() self.ctx.push() init_for("test") db.create_all() init_data() self.client = app.test_client()
from urlparse import urlparse from outreach import init_for, app init_for('dev') REDIS_URL = app.config.get('REDIS_URL', 'redis://localhost:6379/0') # REDIS_URL is not taken by setup_default_arguments function of rq/scripts/__init__.py # so, parse it into pieces and give it r = urlparse(REDIS_URL) REDIS_HOST = r.hostname REDIS_PORT = r.port REDIS_PASSWORD = r.password REDIS_DB = 0
from urlparse import urlparse from outreach import init_for, app init_for('prod') REDIS_URL = app.config.get('REDIS_URL', 'redis://localhost:6379/0') # REDIS_URL is not taken by setup_default_arguments function of rq/scripts/__init__.py # so, parse that into pieces and give it r = urlparse(REDIS_URL) REDIS_HOST = r.hostname REDIS_PORT = r.port REDIS_PASSWORD = r.password REDIS_DB = 0
def create(env): "Creates database tables from sqlalchemy models" init_for(env) db.create_all()
def drop(env): "Drops database tables" init_for(env) if prompt_bool("Are you sure you want to lose all your data?"): db.drop_all()
def run(self, args): if len(args) and not args[0].startswith("-"): init_for(args[0]) super(InitedMigrations, self).run(args[1:])
def handle(self, *args, **kwargs): if "env" in kwargs: init_for(kwargs.pop("env")) super(InitedServer, self).handle(*args, **kwargs)