From d2dc300339998054531f26f684a98530440633d5 Mon Sep 17 00:00:00 2001 From: Felix Delattre <fd@gfz-potsdam.de> Date: Thu, 22 Jul 2021 13:17:07 +0000 Subject: [PATCH] Introduced heartbeat endpoint and changed main url route to /api --- obmdataapi/__init__.py | 11 ++++------- tests/test_obmdataapi.py | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/obmdataapi/__init__.py b/obmdataapi/__init__.py index 1aae402..170f212 100644 --- a/obmdataapi/__init__.py +++ b/obmdataapi/__init__.py @@ -31,14 +31,11 @@ logger.info("obmapidata has started") app = Quart(__name__) app.api = JSONRPCQuart() -app.route( - "/", - methods=[ - "POST", - ], +app.post( + "/v1", )(app.api.handler) @app.api.add_function -async def ping(): - return "pong" +async def heartbeat() -> dict: + return {"status": "healthy"} diff --git a/tests/test_obmdataapi.py b/tests/test_obmdataapi.py index 51b5a7d..2a2f732 100644 --- a/tests/test_obmdataapi.py +++ b/tests/test_obmdataapi.py @@ -23,6 +23,6 @@ from jsonrpcclient import request logger = logging.getLogger() -def test_ping(client): - response = request("http://127.0.0.1:5000/", "ping").data.result - assert "pong" in response +def test_heartbeat(client) -> None: + response = request("http://127.0.0.1:5000/v1", "heartbeat").data.result + assert "healthy" in response["status"] -- GitLab