示例#1
0
import os

from flask_script import Manager, Shell, Server
from flask_script.commands import ShowUrls

from MarathonMR.app import create_app
from MarathonMR.config import ProdConfig, DevConfig

if os.environ.get("ENV") == 'prod':
    app = create_app(ProdConfig)
else:
    app = create_app(DevConfig)

HERE = os.path.abspath(os.path.dirname(__file__))
TEST_PATH = os.path.join(HERE, 'tests')

manager = Manager(app)


def _make_context():
    return {'app': app}


@manager.command
def test():
    import pytest
    exit_code = pytest.main([TEST_PATH, '--verbose'])
    return exit_code

manager.add_command('server', Server(port=1234))
manager.add_command('shell', Shell(make_context=_make_context))
示例#2
0
def testapp(request):
    app = create_app(TestConfig)
    client = app.test_client()
    return client
示例#3
0
def test_production_config():
    app = create_app(ProdConfig)
    assert app.config['ENV'] == 'prod'
    assert app.config['DEBUG'] is False
示例#4
0
def test_test_config():
    app = create_app(TestConfig)
    assert app.config['ENV'] == 'test'
    assert app.config['DEBUG'] is True
示例#5
0
def test_dev_config():
    app = create_app(DevConfig)
    assert app.config['ENV'] == 'dev'
    assert app.config['DEBUG'] is True
示例#6
0
import os

from flask_script import Manager, Shell, Server
from flask_script.commands import ShowUrls

from MarathonMR.app import create_app
from MarathonMR.config import ProdConfig, DevConfig

if os.environ.get("ENV") == 'prod':
    app = create_app(ProdConfig)
else:
    app = create_app(DevConfig)

HERE = os.path.abspath(os.path.dirname(__file__))
TEST_PATH = os.path.join(HERE, 'tests')

manager = Manager(app)


def _make_context():
    return {'app': app}


@manager.command
def test():
    import pytest
    exit_code = pytest.main([TEST_PATH, '--verbose'])
    return exit_code


manager.add_command('server', Server(port=1234))