Skip to content

Commit daa5bf5

Browse files
authored
Add a simple readiness endpoint (#575)
* Add simple readiness endpoint * doc string typos
1 parent 9a4d62a commit daa5bf5

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

gramps_webapi/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,8 @@ def close_user_db_connection(exception) -> None:
193193
if app.config.get("VECTOR_EMBEDDING_MODEL"):
194194
load_model(app.config["VECTOR_EMBEDDING_MODEL"])
195195

196+
@app.route("/ready", methods=["GET"])
197+
def ready():
198+
return {"status": "ready"}, 200
199+
196200
return app

tests/test_endpoints/test_ready.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Gramps Web API - A RESTful API for the Gramps genealogy program
3+
#
4+
# Copyright (C) 2024 David Straub
5+
#
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU Affero General Public License as published by
8+
# the Free Software Foundation; either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Affero General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Affero General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
20+
"""Tests for the /ready endpoint."""
21+
22+
import unittest
23+
24+
from . import get_test_client
25+
26+
27+
class TestBookmarks(unittest.TestCase):
28+
"""Test cases for the /api/ready endpoint."""
29+
30+
@classmethod
31+
def setUpClass(cls):
32+
"""Test class setup."""
33+
cls.client = get_test_client()
34+
35+
def test_ready(self):
36+
"""Test authorization required."""
37+
rv = self.client.get("/ready")
38+
assert rv.status_code == 200
39+
assert rv.json == {"status": "ready"}

0 commit comments

Comments
 (0)