def setUp(self): app = crowdlink.create_app() app.config['TESTING'] = True # Remove flasks stderr handler, replace with stdout so nose can # capture properly del app.logger.handlers[0] try: config_vars = json.load(open(root + '/testing.json')) public = list(six.iteritems(config_vars['public'])) private = list(six.iteritems(config_vars['private'])) config_vars = dict(private + public) for key, val in config_vars.items(): app.config[key] = val except IOError: app.logger.warning("Unable to import testing.json, not using " "testing overrides", exc_info=True) with app.app_context(): self.db = crowdlink.db self.setup_db() self.app = app self._ctx = self.app.test_request_context() self._ctx.push() self.client = self.app.test_client()
from flask.ext.script import Manager from crowdlink import create_app app = create_app() manager = Manager(app) import os import sqlalchemy from crowdlink.mail import TestEmail from crowdlink import db, root from flask import current_app @manager.command def init_db(): try: db.engine.execute("CREATE EXTENSION hstore") except sqlalchemy.exc.ProgrammingError as e: if 'already exists' in str(e): pass else: raise Exception("Unable to enable HSTORE extension") db.session.commit() db.drop_all() db.create_all() @manager.command def provision():