Skip to content

Commit

Permalink
Skip test in old Starlette that does not support HEAD requests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Sep 13, 2024
1 parent 7cc7bb5 commit b86e57a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/integrations/fastapi/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ async def _error():
else:
assert not events


@pytest.mark.asyncio
def test_transaction_http_method_default(sentry_init, capture_events):
"""
Expand All @@ -577,7 +576,7 @@ def test_transaction_http_method_default(sentry_init, capture_events):
sentry_init(
traces_sample_rate=1.0,
integrations=[
StarletteIntegration(),
StarletteIntegration(),
FastApiIntegration(),
],
)
Expand Down Expand Up @@ -610,7 +609,7 @@ def test_transaction_http_method_custom(sentry_init, capture_events):
"OPTIONS",
"head",
), # capitalization does not matter
),
),
FastApiIntegration(
http_methods_to_capture=(
"OPTIONS",
Expand All @@ -629,9 +628,10 @@ def test_transaction_http_method_custom(sentry_init, capture_events):
client.options("/nomessage")
client.head("/nomessage")

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

(event1, event2) = events

assert event1["request"]["method"] == "OPTIONS"
assert event2["request"]["method"] == "HEAD"
assert event2["request"]["method"] == "HEAD"
2 changes: 2 additions & 0 deletions tests/integrations/starlette/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ async def _error(request):
assert not events


@pytest.mark.skipif(STARLETTE_VERSION < (0, 20), reason="Requires Starlette >= 0.20, because earlier versions do not support HTTP 'HEAD' requests")
def test_transaction_http_method_default(sentry_init, capture_events):
"""
By default OPTIONS and HEAD requests do not create a transaction.
Expand All @@ -1229,6 +1230,7 @@ def test_transaction_http_method_default(sentry_init, capture_events):
assert event["request"]["method"] == "GET"


@pytest.mark.skipif(STARLETTE_VERSION < (0, 20), reason="Requires Starlette >= 0.20, because earlier versions do not support HTTP 'HEAD' requests")
def test_transaction_http_method_custom(sentry_init, capture_events):
sentry_init(
traces_sample_rate=1.0,
Expand Down

0 comments on commit b86e57a

Please sign in to comment.