mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-12-22 20:52:19 +01:00
Add /status route
Currently this only prints the API version.
This commit is contained in:
parent
a9d2a6d9be
commit
4b1398c67f
@ -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())
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user