def setUpClass(cls): """ Run once before all tests """ app.debug = False initialize_logging(logging.INFO) # Set up the test database app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI init_db()
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): """ Run once before all tests """ app.debug = False app.testing = True # Set up the test database app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False init_db()
def setUpClass(cls): """ This runs once before the entire test suite """ app.debug = False app.testing = True # setup the test database app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI init_db()
def setUpClass(cls): """ These run once per Test suite """ app.debug = False # Set up the test database if DATABASE_URI: app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI db.drop_all() # clean before all tests init_db()
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() self.headers = { 'X-Api-Key': app.config['API_KEY'] }
def setUp(self): self.app = service.app.test_client() service.initialize_logging(logging.CRITICAL) service.init_db() service.data_reset() service.data_load({ "name": "fido", "category": "dog", "available": True }) service.data_load({ "name": "kitty", "category": "cat", "available": True })
def setUpClass(cls): """ Run once before all tests """ api_key = generate_apikey() app.config['API_KEY'] = api_key app.debug = False initialize_logging(logging.INFO) # Get API key api_key = generate_apikey() app.config['API_KEY'] = api_key # Set up the test database if DATABASE_URI: app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI db.drop_all() # clean before all tests init_db()
def setUp(self): self.app = app.test_client() self.headers = {'X-Api-Key': app.config['API_KEY']} service.init_db("test") service.data_reset() service.data_load({ "name": "fido", "category": "dog", "available": True }) service.data_load({ "name": "kitty", "category": "cat", "available": True }) service.data_load({ "name": "happy", "category": "hippo", "available": False })
# Import the rutes After the Flask app is created from service import service, 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(" P E T S E R V I C E R U N N I N G ".center(70, "*")) app.logger.info(70 * "*") try: service.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!")
def setUpClass(cls): """ These run once per Test suite """ app.debug = False # Set up the test database app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI init_db()
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()
def setUp(self): """ Runs before each test """ init_db() DB.drop_all() DB.create_all() self.app = app.test_client()
""" Module that initiliazes the flask application """ import logging from flask import Flask # Create Flask application app = Flask(__name__) app.config.from_object("config") from service import service, 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(" O R D E R S E R V I C E ".center(70, "*")) app.logger.info(70 * "*") # make our sqlalchemy tables service.init_db() app.logger.info("Service inititalized!")