Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ RUN pip install --upgrade pip
RUN pip install --no-cache-dir --no-input -r requirements.txt
USER backend-user
EXPOSE 80

HEALTHCHECK --interval=30s --timeout=5s CMD curl -H "Origin: localhost" -o /dev/null -s -w "%{http_code}\n" localhost:5000/healthcheck || exit 1
CMD ["fastapi", "run", "./app/main.py", "--host", "0.0.0.0", "--port", "80"]
4 changes: 4 additions & 0 deletions app/routers/main_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

router = APIRouter(dependencies=[Depends(verificar_idioma)])

@router.get("/healthcheck")
async def healthcheck():
return JSONResponse({"status": "ok"}, status_code=200, media_type="application/json")

@router.get("/credenciales")
async def obtener_credenciales(idioma: str = Depends(verificar_idioma)):
try:
Expand Down
14 changes: 13 additions & 1 deletion tests/scripts/routers/test_main_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,16 @@ def test_74(mocker: MockerFixture):
assert RES.status_code == 500
assert RES.json() == {"error": "Error al procesar la solicitud: Error de verificación"}

FUNC.assert_called_once_with("token_valido", "es")
FUNC.assert_called_once_with("token_valido", "es")

def test_91():
"""
Test para validar que el endpoint de healthcheck retorne la respuesta correcta.
"""

CLIENTE = TestClient(app.main.app)

RES = CLIENTE.get("/healthcheck", headers={"Origin": "http://localhost:5178", "Host": "localhost"})

assert RES.status_code == 200
assert RES.json() == {"status": "ok"}