Skip to content

Commit

Permalink
Merge pull request #12 from akvo/refresh-config
Browse files Browse the repository at this point in the history
Implement endpoint to refresh/reload flow config
  • Loading branch information
zuhdil authored Oct 4, 2024
2 parents 87c2dbc + a1d40aa commit 42b3c0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from starlette.responses import StreamingResponse

from app.dependencies import provide_make_bucket, provide_make_form_validator
from app.flow_config import (
get_config,
)
from app.flow_config import get_config, refresh
from app.form_validator import FormValidator
from app.messages import ResultMessage
from app.s3 import S3Bucket
Expand Down Expand Up @@ -142,6 +140,12 @@ async def get_image(
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND) from e


@app.get("/refresh", include_in_schema=False)
async def refresh_config() -> ResultMessage:
refresh()
return ResultMessage.success("OK!")


@app.get("/healtz", include_in_schema=False)
async def healt_check() -> ResultMessage:
return ResultMessage.success("OK!")
8 changes: 8 additions & 0 deletions backend/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,11 @@ def test_get_image_with_invalid_instance_returns_404(fake_bucket):

assert response.status_code == 404
fake_bucket.download.assert_not_called()


def test_refresh():
with patch("app.main.refresh") as mocked_refresh:
response = client.get("/refresh")

assert response.status_code == 200
mocked_refresh.assert_called_once()

0 comments on commit 42b3c0b

Please # to comment.