Skip to content

Commit

Permalink
Merge pull request #26 from internetofwater/healthcheck-endpoint
Browse files Browse the repository at this point in the history
healthcheck endpoint at /about/health
  • Loading branch information
gzt5142 authored Nov 20, 2024
2 parents 92e0cc8 + 5d6e7dd commit ca47e78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/nldi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def healthcheck() -> flask.Response:
return flask.Response(status=http.HTTPStatus.SERVICE_UNAVAILABLE)


@ROOT.router("/about/info")
@ROOT.route("/about/info")
def aboutinfo() -> flask.Response:
"""Simple 'about' properties."""
return flask.jsonify(
Expand Down
19 changes: 17 additions & 2 deletions tests/70_OAS_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
from copy import deepcopy

import pytest

from nldi import __version__
from nldi.api import API
from nldi.api.plugins import *
from nldi.server import APP
from nldi.server import APP, app_factory


@pytest.mark.order(70)
Expand Down Expand Up @@ -46,10 +47,24 @@ def test_get_favicon():
assert response.headers["Content-Type"] == "image/vnd.microsoft.icon"


@pytest.mark.order(60)
@pytest.mark.order(70)
@pytest.mark.unittest
def test_get_openapi():
with APP.test_client() as client:
response = client.get("/api/nldi/openapi?f=json")
assert response.status_code == 200
assert response.headers["Content-Type"] == "application/vnd.oai.openapi+json;version=3.0"


@pytest.mark.order(70)
@pytest.mark.unittest
def test_get_about_stuff(global_config):

## NOTE: the healthcheck endpoint pings the database, so we need to get a valid config:
_api = API(globalconfig=global_config)
_app = app_factory(_api)
with _app.test_client() as client:
response = client.get("/api/nldi/about/info")
assert response.status_code == 200
response = client.get("/api/nldi/about/health")
assert response.status_code == 200

0 comments on commit ca47e78

Please sign in to comment.