ENH: Add root endpoint for App Service health checks (#77)
* ✨ Add health check endpoint * ✅ Add test for health check endpoint
This commit is contained in:
Родитель
4c60ba92ac
Коммит
fc5392ada1
|
@ -63,6 +63,14 @@ def assert_response_error_type(response: TestResponse, status_code: HTTP_STATUS_
|
|||
else:
|
||||
assert 'extra_details' not in response_json
|
||||
|
||||
def test_health_check() -> None:
|
||||
"""
|
||||
Test that the health check endpoint returns 200.
|
||||
"""
|
||||
with app.test_client() as client:
|
||||
response = client.get("/")
|
||||
assert response.status_code == HTTP_STATUS_CODE.OK.value
|
||||
|
||||
|
||||
def test_ping_unauthorized() -> None:
|
||||
"""
|
||||
|
|
10
app.py
10
app.py
|
@ -114,6 +114,16 @@ def is_authenticated_request(req: Request) -> Optional[Response]:
|
|||
return None
|
||||
|
||||
|
||||
@inject
|
||||
@app.route("/", methods=['GET'])
|
||||
def health_check() -> Response:
|
||||
"""
|
||||
Health check endpoint.
|
||||
:return: 200 OK.
|
||||
"""
|
||||
return make_response(jsonify({'status': 'Healthy'}), HTTP_STATUS_CODE.OK.value)
|
||||
|
||||
|
||||
@app.route("/v1/ping", methods=['GET'])
|
||||
def ping() -> Response:
|
||||
authentication_response = is_authenticated_request(request)
|
||||
|
|
Загрузка…
Ссылка в новой задаче