Пример #1
0
def tasks_job():
    """Run subscription tasks."""
    with app.app_context():
        while True:
            subscription = get_subscription()
            if not subscription:
                logging.info("No more subscription tasks to process.")
                break
            process_subscription(subscription)
Пример #2
0
def emails_job():
    """Email job to run every minute."""
    with app.app_context():
        targets = []
        cycle_ids = get_active_cycles()
        if not cycle_ids:
            logging.info("No cycles to process")
            return
        while True:
            target = get_target(cycle_ids)
            if not target:
                logging.info("No more targets found.")
                break
            targets.append(target)
        if targets:
            process_targets(targets)
            logging.info("Processed all targets.")
        else:
            logging.info("No targets to send to.")
Пример #3
0
import os
from sqlalchemy import create_engine
from config import db_uri

# Initialize a db connection
mysql_engine = create_engine(db_uri)
# Create Database if it does not already exist
mysql_engine.execute('CREATE DATABASE IF NOT EXISTS {0}'.format(
    os.getenv('DB_NAME')))
# Import app and db instance and create tables from models
from api.app import app, db
with app.app_context():
    db.create_all()
Пример #4
0
 def setUpClass(cls):
     app.config['SQLALCHEMY_DATABASE_URI'] = BaseTest.SQLALCHEMY_DATABASE_URI
     app.config['DEBUG'] = False
     with app.app_context():
         db.init_app(app)
Пример #5
0
 def setUp(self):
     with app.app_context():
         db.create_all()
     self.client = app.test_client()
     self.app_context = app.app_context()
     self.app_context.push()
Пример #6
0
def app():
    _app.config["TESTING"] = True
    _app.config["SERVER_NAME"] = "localhost"
    with _app.app_context():
        yield _app