def test_create_app(self): """ Test configuring Flask isntance. """ dev_app = create_app('develop', 'test') self.assertIsInstance(dev_app, Flask) self.assertEquals(dev_app.config['ENV'], 'development') test_app = create_app('test', 'test') self.assertIsInstance(test_app, Flask) self.assertEquals(test_app.config['ENV'], 'testing') stage_app = create_app('stage', 'test') self.assertIsInstance(stage_app, Flask) self.assertEquals(stage_app.config['ENV'], 'staging') prod_app = create_app('prod', 'test') self.assertIsInstance(prod_app, Flask) self.assertEquals(prod_app.config['ENV'], 'production')
def execute(self, app_config): app = create_app(app_config) with app.app_context(): try: ponos_db = PonosDB() ponos_q = PonosQueue() while True: self.work_jobs(ponos_db, ponos_q, app.logger) time.sleep(1) except Exception as e: app.logger.error('PonosWorker - {}'.format(e.message))
def create_app(self): app = create_app(config='test') return app
import datetime import os from api.apps import create_app app = create_app(os.getenv('FLASK_CONFIG') or 'develop')
import os import click from api.apps import create_app from api.apps.extensions import mongodb from api.apps.ponos.utilities.mock_data import mock_shift_data, drop_ponos_collections from api.apps.ponos.utilities.tests_cli import (cli_test_ponos_endpoints, cli_test_ponos_middleware, cli_test_ponos_models, cli_test_ponos) from api.apps.ponos.utilities.worker_cli import cli_worker_ponos from api.apps.utilities.test_cli import cli_test_app_config # Initialize Flask object. app = create_app(os.getenv('SHIFTGIG_FLASK_CONFIG') or 'develop') # Shell context. @app.shell_context_processor def make_shell_context(): return dict(app=app, mongo=mongodb) # Unit tests. @app.cli.command() def test_ponos_models(): """Test Ponos models""" cli_test_ponos_models()
#! /usr/local/env python import os import sys sys.path.append( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) from api.apps import create_app app = create_app(config='test') if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)