def setUpClass(cls): """ Run once before all tests """ app.config["TESTING"] = True app.config["DEBUG"] = False app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI app.logger.setLevel(logging.CRITICAL) init_db()
def setUpClass(cls): """ This runs once before the entire test suite """ app.config["TESTING"] = True app.config["DEBUG"] = False app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI app.logger.setLevel(logging.CRITICAL) init_db()
def setUpClass(cls): """ This runs once before the entire test suite """ app.debug = False app.testing = True # Set up the test database app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI init_db()
def setUpClass(cls): """ Run once before all tests """ app.debug = False app.testing = True # Set up the test database app.config[keys.KEY_SQL_ALC] = DATABASE_URI routes.init_db()
def setUp(self): self.app = app.test_client() initialize_logging(logging.CRITICAL) init_db() data_reset() data_load({"name": "fido", "category": "dog", "available": True}) data_load({"name": "kitty", "category": "cat", "available": True})
def setUpClass(cls): """ Run once before all tests """ app.debug = True app.testing = True api_key = routes.generate_apikey() app.config[keys.KEY_API] = api_key app.config[keys.KEY_SQL_ALC] = DATABASE_URI routes.init_db()
def setUp(self): self.app = routes.app.test_client() routes.initialize_logging(logging.INFO) routes.init_db("test") routes.data_reset() routes.data_load({ "name": "fido", "category": "dog", "available": True }) routes.data_load({ "name": "kitty", "category": "cat", "available": False })
def setUp(self): self.app = app.test_client() self.headers = {'X-Api-Key': app.config['API_KEY']} routes.init_db("test") routes.data_reset() routes.data_load({ "name": "fido", "category": "dog", "available": True }) routes.data_load({ "name": "kitty", "category": "cat", "available": True }) routes.data_load({ "name": "happy", "category": "hippo", "available": False })
def setUp(self): """ Runs before each test """ init_db() db.drop_all() # clean up the last tests db.create_all() # create new tables self.app = app.test_client()
# Import the rutes After the Flask app is created from service import routes, models # Set up logging for production if __name__ != "__main__": gunicorn_logger = logging.getLogger("gunicorn.error") app.logger.handlers = gunicorn_logger.handlers app.logger.setLevel(gunicorn_logger.level) app.logger.propagate = False # Make all log formats consistent formatter = logging.Formatter( "[%(asctime)s] [%(levelname)s] [%(module)s] %(message)s", "%Y-%m-%d %H:%M:%S %z" ) for handler in app.logger.handlers: handler.setFormatter(formatter) app.logger.info("Logging handler established") app.logger.info(70 * "*") app.logger.info(" S H O P C A R T S E R V I C E R U N N I N G ".center(70, "*")) app.logger.info(70 * "*") try: routes.init_db() # make our sqlalchemy tables except Exception as error: app.logger.critical("%s: Cannot continue", error) # gunicorn requires exit code 4 to stop spawning workers when they die sys.exit(4) app.logger.info("Service inititalized!")
import os import logging from flask import Flask # Create Flask application app = Flask(__name__) app.config.from_object("config") # Import the routes After the Flask app is created from service import routes, models # Set up logging for production print("Setting up logging for {}...".format(__name__)) app.logger.propagate = False if __name__ != "__main__": gunicorn_logger = logging.getLogger("gunicorn.error") if gunicorn_logger: app.logger.handlers = gunicorn_logger.handlers app.logger.setLevel(gunicorn_logger.level) app.logger.info("Logging established") app.logger.info(70 * "*") app.logger.info(" A U T H O R I Z I N G S E R V E R ".center(70, "*")) app.logger.info(70 * "*") # make our sqlalchemy tables routes.init_db() app.logger.info("Service initialized!")