"""This file tests logging function of an app.""" from daemon_asset_copy.connectors import logger def clear_handlers(): """Remove all handlers from apps logger.""" for h in logger.app_logger.handlers: logger.app_logger.removeHandler(h) def test_current_logger_correlation_id(): """Test correlation_id link with logging adapter. Test whether correlation_id is assigned to logging adapter, when using get_current_logger(correlation_id) function. """ correlation_id = 'test_correlation_id' current_logger = logger.get_current_logger(correlation_id) assert 'correlation_id' in current_logger.extra assert current_logger.extra['correlation_id'] == correlation_id def teardown_module(module): """Clear all handlers when app tears down.""" clear_handlers()