diff --git a/openapi.yaml b/openapi.yaml index 775522f..1e89e41 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -35,6 +35,17 @@ info: version: 0.1.0 openapi: 3.0.2 paths: + /health: + get: + description: Used to test if this service is alive + operationId: health_health_get + responses: + '200': + content: + application/json: + schema: {} + description: Successful Response + summary: health /values: get: description: Retrieves all values from the WellKnownsConfig class diff --git a/src/wkvs/adapters/inbound/fastapi_/routes.py b/src/wkvs/adapters/inbound/fastapi_/routes.py index 9bce5dd..7b512db 100644 --- a/src/wkvs/adapters/inbound/fastapi_/routes.py +++ b/src/wkvs/adapters/inbound/fastapi_/routes.py @@ -28,6 +28,16 @@ router = APIRouter() +@router.get( + "/health", + summary="health", + status_code=status.HTTP_200_OK, +) +async def health(): + """Used to test if this service is alive""" + return {"status": "OK"} + + @router.get( "/values/{value_name}", summary="retrieve a configured value", diff --git a/tests/test_api.py b/tests/test_api.py index ecd186e..ed906ae 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -20,6 +20,15 @@ from tests.fixtures.joint import JointFixture, joint_fixture # noqa: F401 +@pytest.mark.asyncio +async def test_health_check(joint_fixture: JointFixture): # noqa: F811 + """Test that the health check endpoint works.""" + response = await joint_fixture.rest_client.get("/health") + + assert response.status_code == 200 + assert response.json() == {"status": "OK"} + + @pytest.mark.asyncio async def test_happy_retrieval(joint_fixture: JointFixture): # noqa: F811 """Test that configured values can be retrieved"""