Пример #1
0
def test_config(monkeypatch):
    # Default config
    assert not create_app().testing

    # Test config
    assert create_app({'TESTING': True}).testing

    # Prod config
    monkeypatch.setenv('DATABASE_URL', "pretend this is on heroku...")
    assert "heroku" in create_app().config['DB_URL']
    assert "require" in create_app().config['DB_SSLMODE']
Пример #2
0
def app(faker):
    app = create_app(TestConfig)
    app.test_client_class = CustomClient
    context = app.test_request_context()
    context.push()
    db.create_all()

    yield app

    context.pop()
Пример #3
0
def client_with_crsf(faker):
    app = create_app(TestConfigCRSF)
    app.test_client_class = CustomClient
    context = app.test_request_context()
    context.push()
    db.create_all()

    client = app.test_client()

    yield client

    context.pop()
Пример #4
0
def app():
    """Create an app configured for tests."""

    app = create_app({
        'TESTING': True,
        'DB_URL': "postgresql://portal_user@localhost/portal_test"
    })

    with app.app_context():
        db.init_db()
        db.mock_db()

    yield app
Пример #5
0
def app():
    app = create_app({
        'TESTING': True,
        'DB_NAME': 'portal_test',
        'DB_USER': '******',
    })

    with app.app_context():
        init_db()

        with open(os.path.join(os.path.dirname(__file__), 'data.sql'),
                  'rb') as f:
            with get_db() as con:
                with con.cursor() as cur:
                    cur.execute(f.read())

    yield app
Пример #6
0
def app():
    app = create_app({
        'TESTING': True,
        'DB_NAME': 'portal_test',
        'DB_USER': '******',
        'EMAIL': '*****@*****.**',
        'PASSWORD': '******',
    })

    with app.app_context():
        init_db()

        with open(os.path.join(os.path.dirname(__file__), 'data.sql'),
                  'rb') as f:
            con = get_db()
            cur = con.cursor()
            cur.execute(f.read())
            cur.close()
            con.commit()
            con.close()

    yield app
Пример #7
0
def app():
    db_fd, db_path = tempfile.mkstemp()

    app = create_app({
        'TESTING': True,
        'DATABASE': db_path,
    })

    with app.app_context():
        init_db()
        get_db().executescript(_data_sql)

    yield app

    os.close(db_fd)
    os.unlink(db_path)

    @pytest.fixture
    def client(app):
        return app.test_client()

    @pytest.fixture
    def runner(app):
        return app.test_cli_runner()
Пример #8
0
def test_config():
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
Пример #9
0
from portal import create_app

# application = app
app = create_app()

if __name__ == '__main__':
    app.run(debug=True)
Пример #10
0
#!/usr/bin/env python3

import os
from dotenv import load_dotenv
from celery.task.control import inspect
from flask import url_for
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Load environment variables from '.env' file.
load_dotenv()

from portal import create_app

application = create_app()
application.app_context().push()

application.config['SERVER_NAME'] = os.environ["CELERY_SERVER_NAME"]

from portal.celery import celery
Пример #11
0
def app():
    app = create_app()
    return app
Пример #12
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     Role.insert_roles()
Пример #13
0
# -*- coding:utf-8 -*-
# author : BieFeNg
# date_time 2020/01/17 23:06
# file_name : wsgi.py

import sys

from portal import create_app

if sys.version_info[0] == 2:
    reload(sys)
else:
    import importlib

    importlib.reload(sys)

if sys.getdefaultencoding() != 'utf-8':
    sys.setdefaultencoding("utf-8")

portal = create_app()