diff --git a/dspace_statistics_api/app.py b/dspace_statistics_api/app.py index d0052e3..fe6ffa2 100644 --- a/dspace_statistics_api/app.py +++ b/dspace_statistics_api/app.py @@ -5,6 +5,7 @@ from falcon_swagger_ui import register_swaggerui_app from .database import DatabaseManager from .stats import get_downloads, get_views from .util import set_statistics_scope, validate_post_parameters +from .config import VERSION class RootResource: @@ -15,6 +16,14 @@ class RootResource: resp.body = f.read() +class StatusResource: + def on_get(self, req, resp): + message = {"version": VERSION} + + resp.status = falcon.HTTP_200 + resp.media = message + + class OpenAPIJSONResource: def on_get(self, req, resp): resp.status = falcon.HTTP_200 @@ -174,6 +183,7 @@ class SingleStatisticsResource: api = application = falcon.API() api.add_route("/", RootResource()) +api.add_route("/status", StatusResource()) # Item routes api.add_route("/items", AllStatisticsResource()) diff --git a/dspace_statistics_api/config.py b/dspace_statistics_api/config.py index 844b4ba..3fc33ca 100644 --- a/dspace_statistics_api/config.py +++ b/dspace_statistics_api/config.py @@ -9,4 +9,6 @@ DATABASE_PASS = os.environ.get("DATABASE_PASS", "dspacestatistics") DATABASE_HOST = os.environ.get("DATABASE_HOST", "localhost") DATABASE_PORT = os.environ.get("DATABASE_PORT", "5432") +VERSION = "1.4.0-dev" + # vim: set sw=4 ts=4 expandtab: diff --git a/tests/test_api_docs.py b/tests/test_api_docs.py index 0878911..62188ab 100644 --- a/tests/test_api_docs.py +++ b/tests/test_api_docs.py @@ -34,3 +34,12 @@ def test_get_swagger_ui(client): assert isinstance(response.content, bytes) assert response.status_code == 200 + + +def test_get_status(client): + """Test requesting the status page.""" + + response = client.simulate_get("/status") + + assert isinstance(response.content, bytes) + assert response.status_code == 200