Exemple #1
0
def app(username, password):
    tmp = make_tmp()
    with open(os.path.join(tmp, 'static.json'), 'w') as f:
        json.dump(
            {
                'user': username,
                'password': generate_password_hash(password),
                'main_log': "main.log"
            }, f)
    yield create_app({'TESTING': True, 'DATA_DIR': tmp})
    shutil.rmtree(tmp)
Exemple #2
0

# Note: This function will be removed during deployment.
def extra_files():
    """
    Watch files and reload the server when they change.
    """

    import os

    extra_dirs = ['frontend/static', 'frontend/templates']

    extra_files = extra_dirs[:]
    for extra_dir in extra_dirs:
        for dirname, dirs, files in os.walk(extra_dir):
            for filename in files:
                filename = os.path.join(dirname, filename)
                if os.path.isfile(filename):
                    extra_files.append(filename)

    return extra_files


if __name__ == '__main__':
    app = create_app()
    run_simple(hostname=app.config['SERVER_HOSTNAME'],
               port=app.config['SERVER_PORT'],
               application=app,
               use_reloader=app.debug,
               extra_files=extra_files())
Exemple #3
0
from werkzeug.contrib.fixers import ProxyFix
from frontend import create_app

application = create_app()
application.wsgi_app = ProxyFix(application.wsgi_app)
Exemple #4
0
def test_development_environment_sets_secret_to_dev(environment):
    environment['FLASK_ENV'] = "development"
    assert create_app().config['SECRET_KEY'] == 'dev'
Exemple #5
0
def test_default_creation_uses_instance_path_as_data_dir():
    app = create_app()
    assert app.config['DATA_DIR'] == app.instance_path
Exemple #6
0
def test_create_instance_path(makedirs):
    app = create_app()
    assert makedirs.path == app.instance_path and makedirs.exist_ok
Exemple #7
0
def test_creating_a_test_environment():
    app = create_app({'TESTING': True})
    assert app.testing and app.config['SECRET_KEY'] == 'dev'
Exemple #8
0
def test_load_config_from_json_by_default(from_json):
    create_app()
    assert from_json.file == "config.json" and from_json.silent
Exemple #9
0
def test_not_using_dev_secret_by_default():
    assert 'dev' != create_app().config['SECRET_KEY']
Exemple #10
0
def test_creating_non_test_env_by_default():
    assert not create_app().testing
Exemple #11
0
    Watch files and reload the server when they change.
    """

    import os

    extra_dirs = [
        'frontend/static',
        'frontend/templates'
    ]

    extra_files = extra_dirs[:]
    for extra_dir in extra_dirs:
        for dirname, dirs, files in os.walk(extra_dir):
            for filename in files:
                filename = os.path.join(dirname, filename)
                if os.path.isfile(filename):
                    extra_files.append(filename)

    return extra_files


if __name__ == '__main__':
    app = create_app()
    run_simple(
        hostname=app.config['SERVER_HOSTNAME'],
        port=app.config['SERVER_PORT'],
        application=app,
        use_reloader=app.debug,
        extra_files=extra_files()
    )
Exemple #12
0
from frontend import create_app
from flask_script import Manager, Server

app = create_app('develop')
manager = Manager(app)
manager.add_command('server', Server)


@manager.command
def test():
    """Run the unit tests."""
    import unittest
    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)


if __name__ == '__main__':
    manager.run()
def app():
    _app = frontend.create_app(test_settings)
    ctx = _app.test_request_context()
    ctx.push()
    yield _app
    ctx.pop()
 def create_app(self):
   app = create_app(TestingConfig)
   return app
Exemple #15
0
"""Application entry point."""

import frontend

app = frontend.create_app()

if __name__ == "__main__":
    app.run(host="0.0.0.0")