Skip to content

Commit

Permalink
add health endpoint to the service API (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
dontseyit authored Oct 13, 2023
1 parent ee47210 commit bd01ace
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/metldata/artifacts_rest/api_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
14 changes: 14 additions & 0 deletions tests/artifact_rest/test_api_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bd01ace

Please sign in to comment.