def create_app(config=None): app = Flask(__name__) app_config = f"config.{config or os.environ.get('APP_SETTINGS', 'Config')}" app.config.from_object(app_config) app.name = 'ras-rm-auth-service' logger_initial_config(log_level=app.config['LOGGING_LEVEL']) app.url_map.strict_slashes = False from ras_rm_auth_service.resources.info import info_view # NOQA # pylint: disable=wrong-import-position from ras_rm_auth_service.resources.account import account # NOQA # pylint: disable=wrong-import-position from ras_rm_auth_service.resources.tokens import tokens # NOQA # pylint: disable=wrong-import-position from ras_rm_auth_service.batch_process_endpoints import batch app.register_blueprint(info_view) app.register_blueprint(account) app.register_blueprint(tokens) app.register_blueprint(batch) try: initialise_db(app) except RetryError: logger.exception('Failed to initialise database') exit(1) logger.info('App and database successfully initialised', app_name=app.name, version=app.config['VERSION']) return app
def test_indent_value_error(self, list): logger_initial_config() logger = wrap_logger(logging.getLogger()) logger.error('Test') message = list.records[0].msg self.assertIn('"event": "Test", ', message) self.assertIn('"severity": "error", ', message) self.assertIn('"level": "error", ', message) self.assertIn('"service": "ras-rm-auth-service", ', message)
def test_indent_type_error(self, list): os.environ['JSON_INDENT_LOGGING'] = 'abc' logger_initial_config() logger = wrap_logger(logging.getLogger()) logger.error('Test') message = list.records[0].msg self.assertIn('"event": "Test", ', message) self.assertIn('"severity": "error", ', message) self.assertIn('"level": "error", ', message) self.assertIn('"service": "ras-rm-auth-service", ', message)
def test_success(self, list): os.environ["JSON_INDENT_LOGGING"] = "1" logger_initial_config() logger = wrap_logger(logging.getLogger()) logger.error("Test") message = list.records[0].msg self.assertIn('"event": "Test",\n ', message) self.assertIn('"severity": "error",\n ', message) self.assertIn('"level": "error",\n ', message) self.assertIn('"service": "ras-rm-auth-service",\n ', message)