Skip to content

Commit 6e4f3c7

Browse files
committed
Add tests
1 parent 47b88db commit 6e4f3c7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/integrations/litestar/test_litestar.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22
import functools
33

4+
from litestar.exceptions import HTTPException
45
import pytest
56

67
from sentry_sdk import capture_message
@@ -16,6 +17,8 @@
1617
from litestar.middleware.session.server_side import ServerSideSessionConfig
1718
from litestar.testing import TestClient
1819

20+
from tests.integrations.starlette import test_starlette
21+
1922

2023
def litestar_app_factory(middleware=None, debug=True, exception_handlers=None):
2124
class MyController(Controller):
@@ -396,3 +399,25 @@ async def __call__(self, scope, receive, send):
396399
}
397400
else:
398401
assert "user" not in event
402+
@test_starlette.parametrize_test_configurable_status_codes
403+
def test_configurable_status_codes(
404+
sentry_init,
405+
capture_events,
406+
failed_request_status_codes,
407+
status_code,
408+
expected_error,
409+
):
410+
integration_kwargs = {"failed_request_status_codes": failed_request_status_codes} if failed_request_status_codes is not None else {}
411+
sentry_init(integrations=[LitestarIntegration(**integration_kwargs)])
412+
413+
events = capture_events()
414+
415+
@get("/error")
416+
async def error()-> None:
417+
raise HTTPException(status_code=status_code)
418+
419+
app = Litestar([error])
420+
client = TestClient(app)
421+
client.get("/error")
422+
423+
assert len(events) == int(expected_error)

0 commit comments

Comments
 (0)