From 14e97f1be343ee5b8d413e3422b397e66e3fb4bb Mon Sep 17 00:00:00 2001 From: Colin Goutte Date: Wed, 20 Oct 2021 12:28:29 +0200 Subject: [PATCH] reindent for tests --- papi/main.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/papi/main.py b/papi/main.py index 651d50a..07036c0 100644 --- a/papi/main.py +++ b/papi/main.py @@ -217,22 +217,29 @@ def post_sonde_error( db: Session = Depends(get_db), ): if not (sonde := crud.get_sonde(db, idsonde)): - return # pragma: no cover - Notifier.error_sonde(idsonde) + if idsonde != "test": + return # pragma: no cover + + Notifier.error_sonde(idsonde, body["msg"]) + # create fake sample - last = list(crud.get_mesure(db, sonde.sonde_id, only_last=1))[0] - from copy import copy + try: + last = list(crud.get_mesure(db, sonde.sonde_id, only_last=1))[0] + except IndexError: + pass + else: + from copy import copy - api_error = copy(last.content) - from datetime import datetime + api_error = copy(last.content) + from datetime import datetime - date = str(datetime.now()) - for channel in api_error["channels"]: - channel["status"] = "perte contact api" + date = str(datetime.now()) + for channel in api_error["channels"]: + channel["status"] = "perte contact api" - api_error["date"] = date + api_error["date"] = date - post_sonde_data(request, idsonde, body=api_error, db=db) + post_sonde_data(request, idsonde, body=api_error, db=db) return