def mocked_statsd(mocker, mocked_config): """Mocked version of the StatsD class for unit test usage.""" statsd = StatsClient(mocked_config.statsd_config) mocked_statsd = mocker.MagicMock(spec=statsd) yield mocked_statsd
app.config['DIRBS_CONFIG'] = cp.parse_config(ignore_env=False) except ConfigParseException: logger = logging.getLogger('dirbs.config') logger.critical( 'Exception encountered during parsing of config (.yml file). ' 'See console above for details...') sys.exit(1) # Update the logging based on the parsed config configure_logging(app.config['DIRBS_CONFIG'].log_config) # Initialize file logging setup_file_logging(app.config['DIRBS_CONFIG'].log_config, 'dirbs-api') # Init statsd client statsd = StatsClient(app.config['DIRBS_CONFIG'].statsd_config) # Init custom JSONEncoder (handles dates, etc.) app.json_encoder = utils.JSONEncoder def _metrics_type_from_req_ctxt(req: callable) -> str: """ Utility method to get a metrics path for the API type. Arguments: req: intercepted http request object Returns: str: representing API type & version """ p = req.path.split('/')