Skip to content

Commit

Permalink
Added tests for http_methods_to_capture to Fastapi
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Sep 13, 2024
1 parent 1518f5d commit 583c09b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/integrations/fastapi/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ async def _message():
capture_message("Hi")
return {"message": "Hi"}

@app.delete("/nomessage")
@app.get("/nomessage")
@app.head("/nomessage")
@app.options("/nomessage")
@app.patch("/nomessage")
@app.post("/nomessage")
@app.put("/nomessage")
@app.trace("/nomessage")
async def _nomessage():
return {"message": "nothing here..."}

Expand Down Expand Up @@ -559,7 +566,7 @@ async def _error():
assert not events

@pytest.mark.asyncio
def test_transaction_http_method_default(sentry_init, client, capture_events):
def test_transaction_http_method_default(sentry_init, capture_events):
"""
By default OPTIONS and HEAD requests do not create a transaction.
"""
Expand All @@ -583,15 +590,14 @@ def test_transaction_http_method_default(sentry_init, client, capture_events):
client.options("/nomessage")
client.head("/nomessage")

import ipdb; ipdb.set_trace()
assert len(events) == 1

(event,) = events

assert event["request"]["method"] == "GET"


def test_transaction_http_method_custom(sentry_init, client, capture_events):
def test_transaction_http_method_custom(sentry_init, capture_events):
# FastAPI is heavily based on Starlette so we also need
# to enable StarletteIntegration.
# In the future this will be auto enabled.
Expand Down Expand Up @@ -622,7 +628,6 @@ def test_transaction_http_method_custom(sentry_init, client, capture_events):
client.options("/nomessage")
client.head("/nomessage")

import ipdb; ipdb.set_trace()
assert len(events) == 2

(event1, event2) = events
Expand Down

0 comments on commit 583c09b

Please sign in to comment.