[docs]defcheck_all_dependencies():""" Check all dependencies are available. This function checks that the database and the redis server are available. Returns ------- dict The value for each key is a boolean indicating if the connection is available or not. """check={"database_connection":{"status":True,"message":"The database is available"},"redis_connection":{"status":True,"message":"The redis server is available"},"celery_worker":{"status":True,"message":"The celery worker is available"},}try:db.session.execute("SELECT 1")exceptExceptionase:check["database_connection"]={"status":False,"message":f"The database is not available",}try:if"CELERY"incurrent_app.config:r=redis.from_url(current_app.config["CELERY"]["broker_url"])r.ping()exceptredis.ConnectionError:check["redis_connection"]={"status":False,"message":"The redis server is not available",}if"CELERY"incurrent_app.config:ifcheck["redis_connection"]["status"]:fromgeonature.utils.celeryimportcelery_appis_pytest=current_app.config["CELERY"].get("task_always_eager",False)ifnotis_pytestandnotcelery_app.control.inspect().active():check["celery_worker"]={"status":False,"message":"The celery worker is not running",}else:check["celery_worker"]={"status":False,"message":"The celery worker is not accessible because the redis server is not available",}returncheck