Skip to content

Commit

Permalink
fix(test): fix tests that broke with path prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
ividito committed Sep 22, 2023
1 parent 2a4108b commit eb13fc3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions api/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,16 @@ def who_am_i(claims=Depends(auth.decode_token)):
return claims


app.include_router(api_router)


# exception handling
@api_router.exception_handler(RequestValidationError)
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request, exc):
return JSONResponse(str(exc), status_code=422)


@api_router.middleware("http")
@app.middleware("http")
async def add_correlation_id(request: Request, call_next):
"""Add correlation ids to all requests and subsequent logs/traces"""
# Get correlation id from X-Correlation-Id header if provided
Expand Down
1 change: 1 addition & 0 deletions api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_environ():
os.environ["RASTER_URL"] = "https://test-raster.url"
os.environ["USERPOOL_ID"] = "fake_id"
os.environ["STAGE"] = "testing"
os.environ["PATH_PREFIX"] = "/api/ingest"


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion api/tests/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fastapi.testclient import TestClient
from src import schemas, services

ingestion_endpoint = "/ingestions"
ingestion_endpoint = "/api/ingest/ingestions"


class TestList:
Expand Down

0 comments on commit eb13fc3

Please sign in to comment.