Beispiel #1
0
def create_mock_app():
    from cites.app import create_app
    from cites import database

    config = {
        "DATABASE": "cites_test",
        "DATABASE_URI": "postgresql://localhost/cites_test",
        "TESTING": True,
        "CSRF_ENABLED": False,
        "RECAPTCHA_DISABLED": True,
        "MAIL_SUPPRESS_SEND": True,
        "UPLOADED_PHOTO_RESOLUTION": (640, 770),
        "PHOTO_REQUIRED": False,
        "UPLOADED_PHOTOS_DEST": path(tempfile.mkdtemp()),
        "UPLOADED_FILES_DEST": path(tempfile.mkdtemp()),
    }

    local_config = create_app().config
    for name, value in local_config.iteritems():
        if name.startswith("TESTING_"):
            config[name[len("TESTING_") :]] = value

    app = create_app(config=config)
    database.initialize_app(app)
    drop_tables()
    create_tables()

    def app_teardown():
        pass

    return app, app_teardown
Beispiel #2
0
def create_mock_app():
    from cites.app import create_app
    from cites import database

    config = {
        'DATABASE': 'cites_test',
        'DATABASE_URI': 'postgresql://localhost/cites_test',
        'TESTING': True,
        'CSRF_ENABLED': False,
        'RECAPTCHA_DISABLED': True,
        'MAIL_SUPPRESS_SEND': True,
        'UPLOADED_PHOTO_RESOLUTION': (640, 770),
        'PHOTO_REQUIRED': False,
        'UPLOADED_PHOTOS_DEST': path(tempfile.mkdtemp()),
        'UPLOADED_FILES_DEST': path(tempfile.mkdtemp()),
    }
    app = create_app(config=config)
    database.initialize_app(app)
    drop_tables()
    create_tables()

    def app_teardown():
        pass

    return app, app_teardown
Beispiel #3
0
def _get_testing_db_uri():
    global _testing_db_uri
    from cites.app import create_app
    if _testing_db_uri is None:
        tmp_app = create_app()
        _testing_db_uri = tmp_app.config['TESTING_DATABASE_URI']
    return _testing_db_uri
Beispiel #4
0
def create_mock_app():
    from cites.app import create_app
    from cites import database

    app = create_app()
    app.config["DATABASE_URI"] = _get_testing_db_uri()
    app.config["TESTING"] = True
    app.config["MAIL_SUPPRESS_SEND"] = True
    database.initialize_app(app)
    with app.test_request_context():
        database.get_session().create_all()

    def app_teardown():
        with app.test_request_context():
            database.get_session().drop_all()

    return app, app_teardown
Beispiel #5
0
def make_celery_flask_app():
    from cites.app import create_app
    instance_path = os.environ['FLASK_INSTANCE_PATH']
    return create_app(instance_path)