def client():
    _app = create_app('testing')
    db.create_all(app=_app)
    register_blueprints(_app)
    with _app.app_context():
        yield _app
    db.drop_all(app=_app)
Пример #2
0
def test_index_200():
    """Makes sure the front page returns HTTP 200.
    A very basic test, if the front page is broken, something has obviously failed.
    """
    app = Flask(__name__)
    register_blueprints(app)
    assert '200 OK' == app.test_client().get('/').status
Пример #3
0
def client():
    """Create a database in the application context for testing"""
    register_blueprints()

    with app.test_client() as client:
        with app.app_context():
            Base.metadata.create_all(engine)
            ItemModel.clear_db()
            UserModel.clear_db()
            if UserModel.find_by_username("admin") is None:
                admin = UserModel("admin", "Passw0rd")
                admin.save_to_db()
        yield client
Пример #4
0
import os

from app import create_app
from config import config_dict
from decouple import config
from app import register_blueprints
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.log import enable_pretty_logging

if os.getenv('PRODUCTION') is None:
    DEBUG = config('DEBUG', default=True, cast=bool)
else:
    DEBUG = False
get_config_mode = 'Debug' if DEBUG else 'Production'
app_config = config_dict[get_config_mode.capitalize()]

app = create_app(app_config)
register_blueprints(app)

if __name__ == '__main__':
    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(port=5000, address='0.0.0.0')
    enable_pretty_logging()
    IOLoop.current().start()

Пример #5
0
def test_index():
    app = Flask(__name__)
    register_blueprints(app)
    assert '200 OK' == app.test_client().get('/').status
Пример #6
0
def test_404():
    app = Flask(__name__)
    register_blueprints(app)
    assert '404 NOT FOUND' == app.test_client().get('/asdasdasdasfdaf').status
Пример #7
0
def test_modules():
    app = Flask(__name__)
    register_blueprints(app)
    assert '200 OK' == app.test_client().get('/settings').status
Пример #8
0
def test_approve():
    app = Flask(__name__)
    register_blueprints(app)
    assert '200 OK' == app.test_client().get('/good_domains').status
Пример #9
0
from app import create_app, register_blueprints, run

create_app()
register_blueprints()
run()
Пример #10
0
from app import flask_app
from app import register_blueprints
from app import setup_db

register_blueprints(flask_app)
setup_db()

if __name__ == '__main__':
    flask_app.run()