Skip to content
Merged
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
35 changes: 23 additions & 12 deletions tests/integrations/httpx/test_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import httpx
import pytest
import responses

import sentry_sdk
from sentry_sdk import capture_message, start_transaction
Expand All @@ -16,15 +15,16 @@
"httpx_client",
(httpx.Client(), httpx.AsyncClient()),
)
def test_crumb_capture_and_hint(sentry_init, capture_events, httpx_client):
def test_crumb_capture_and_hint(sentry_init, capture_events, httpx_client, httpx_mock):
httpx_mock.add_response()

def before_breadcrumb(crumb, hint):
crumb["data"]["extra"] = "foo"
return crumb

sentry_init(integrations=[HttpxIntegration()], before_breadcrumb=before_breadcrumb)

url = "http://example.com/"
responses.add(responses.GET, url, status=200)

with start_transaction():
events = capture_events()
Expand Down Expand Up @@ -61,11 +61,15 @@ def before_breadcrumb(crumb, hint):
"httpx_client",
(httpx.Client(), httpx.AsyncClient()),
)
def test_outgoing_trace_headers(sentry_init, httpx_client):
sentry_init(traces_sample_rate=1.0, integrations=[HttpxIntegration()])
def test_outgoing_trace_headers(sentry_init, httpx_client, httpx_mock):
httpx_mock.add_response()

sentry_init(
traces_sample_rate=1.0,
integrations=[HttpxIntegration()],
)

url = "http://example.com/"
responses.add(responses.GET, url, status=200)

with start_transaction(
name="/interactions/other-dogs/new-dog",
Expand Down Expand Up @@ -93,15 +97,20 @@ def test_outgoing_trace_headers(sentry_init, httpx_client):
"httpx_client",
(httpx.Client(), httpx.AsyncClient()),
)
def test_outgoing_trace_headers_append_to_baggage(sentry_init, httpx_client):
def test_outgoing_trace_headers_append_to_baggage(
sentry_init,
httpx_client,
httpx_mock,
):
httpx_mock.add_response()

sentry_init(
traces_sample_rate=1.0,
integrations=[HttpxIntegration()],
release="d08ebdb9309e1b004c6f52202de58a09c2268e42",
)

url = "http://example.com/"
responses.add(responses.GET, url, status=200)

with start_transaction(
name="/interactions/other-dogs/new-dog",
Expand Down Expand Up @@ -290,12 +299,13 @@ def test_do_not_propagate_outside_transaction(sentry_init, httpx_mock):


@pytest.mark.tests_internal_exceptions
def test_omit_url_data_if_parsing_fails(sentry_init, capture_events):
def test_omit_url_data_if_parsing_fails(sentry_init, capture_events, httpx_mock):
httpx_mock.add_response()

sentry_init(integrations=[HttpxIntegration()])

httpx_client = httpx.Client()
url = "http://example.com"
responses.add(responses.GET, url, status=200)

events = capture_events()
with mock.patch(
Expand Down Expand Up @@ -326,7 +336,9 @@ def test_omit_url_data_if_parsing_fails(sentry_init, capture_events):
"httpx_client",
(httpx.Client(), httpx.AsyncClient()),
)
def test_span_origin(sentry_init, capture_events, httpx_client):
def test_span_origin(sentry_init, capture_events, httpx_client, httpx_mock):
httpx_mock.add_response()

sentry_init(
integrations=[HttpxIntegration()],
traces_sample_rate=1.0,
Expand All @@ -335,7 +347,6 @@ def test_span_origin(sentry_init, capture_events, httpx_client):
events = capture_events()

url = "http://example.com/"
responses.add(responses.GET, url, status=200)

with start_transaction(name="test_transaction"):
if asyncio.iscoroutinefunction(httpx_client.get):
Expand Down
Loading