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))
def testapp(request): app = create_app(TestConfig) client = app.test_client() return client
def test_production_config(): app = create_app(ProdConfig) assert app.config['ENV'] == 'prod' assert app.config['DEBUG'] is False
def test_test_config(): app = create_app(TestConfig) assert app.config['ENV'] == 'test' assert app.config['DEBUG'] is True
def test_dev_config(): app = create_app(DevConfig) assert app.config['ENV'] == 'dev' assert app.config['DEBUG'] is True
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))