diff --git a/src/metldata/artifacts_rest/api_factory.py b/src/metldata/artifacts_rest/api_factory.py index 5fa4fb81..1eaab54e 100644 --- a/src/metldata/artifacts_rest/api_factory.py +++ b/src/metldata/artifacts_rest/api_factory.py @@ -53,6 +53,11 @@ async def rest_api_factory( router = APIRouter() + @router.get("/health") + async def health() -> dict[str, str]: + """Used to test if this service is alive""" + return {"status": "OK"} + @router.options("/artifacts") async def get_artifacts_info() -> list[ArtifactInfo]: """Get information on available artifacts.""" diff --git a/tests/artifact_rest/test_api_factory.py b/tests/artifact_rest/test_api_factory.py index 498488e1..361de5f6 100644 --- a/tests/artifact_rest/test_api_factory.py +++ b/tests/artifact_rest/test_api_factory.py @@ -52,6 +52,20 @@ async def get_example_app_client( return AsyncTestClient(app) +@pytest.mark.asyncio +async def test_health_check( + mongodb_fixture: MongoDbFixture, # noqa: F811 +): + """Test that the health check endpoint works.""" + async with await get_example_app_client( + dao_factory=mongodb_fixture.dao_factory + ) as client: + response = await client.get("/health") + + assert response.status_code == 200 + assert response.json() == {"status": "OK"} + + @pytest.mark.asyncio async def test_artifacts_info_endpoint( mongodb_fixture: MongoDbFixture, # noqa: F811