From adb69278c846ce444865450c50ec2a696bca30ce Mon Sep 17 00:00:00 2001 From: Colin Goutte Date: Wed, 29 Sep 2021 15:34:25 +0200 Subject: [PATCH] Test routing ok --- papi/main.py | 7 ++++++- tests/test_papi.py | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/papi/main.py b/papi/main.py index b298a59..230fc1e 100644 --- a/papi/main.py +++ b/papi/main.py @@ -72,11 +72,16 @@ def list_sonde(): return [x for x in sondes.values()] -@app.get("/notifications/{idsonde}/") +@app.get("/notifications/{idsonde}") def list_notification(idsonde: str): return notifications[idsonde][::-1] +@app.get("/notifications/{idsonde}/text") +def list_notification_as_text(idsonde: str): + return "Contenu" + + @app.post("/sonde/{idsonde}/") def post_sonde_data( idsonde: str, body: dict = Body(...), db: Session = Depends(get_db) diff --git a/tests/test_papi.py b/tests/test_papi.py index 6329fae..da2e6a3 100644 --- a/tests/test_papi.py +++ b/tests/test_papi.py @@ -149,10 +149,11 @@ def test_onchange_notification(): def test_template_rendering(): - id_sonde = "masonde_histo" - notifs_text = client.get(f"/notifications/{idsonde}.txt") + idsonde = "masonde_histo" + notifs_text = client.get(f"/notifications/{idsonde}/text") assert notifs_text.ok - # assert something in notif_text.body ? + content = notifs_text + assert "contenu" in content.text.lower() class CodeCoverageTestCase(TestCase):