Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana committed Sep 20, 2024
1 parent 2ca480a commit 1c1a4b0
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions tests/integrations/django/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from django import VERSION as DJANGO_VERSION
from django.contrib.auth.models import User
from django.core.handlers.wsgi import WSGIRequest
from django.core.management import execute_from_command_line
from django.db.utils import OperationalError, ProgrammingError, DataError
from django.http.request import RawPostDataException
Expand All @@ -23,7 +22,11 @@
from sentry_sdk._compat import PY310
from sentry_sdk import capture_message, capture_exception
from sentry_sdk.consts import SPANDATA
from sentry_sdk.integrations.django import DjangoIntegration, _set_db_data
from sentry_sdk.integrations.django import (
DjangoIntegration,
DjangoRequestExtractor,
_set_db_data,
)
from sentry_sdk.integrations.django.signals_handlers import _get_receiver_name
from sentry_sdk.integrations.executing import ExecutingIntegration
from sentry_sdk.tracing import Span
Expand Down Expand Up @@ -748,24 +751,19 @@ def test_request_body_already_read(sentry_init, client, capture_events):

events = capture_events()

class MockRequest(WSGIRequest):
@property
def body(self):
class MockExtractor(DjangoRequestExtractor):
def raw_data(self):
raise RawPostDataException

@property
def data(self):
raise AttributeError

with patch("django.core.handlers.wsgi.WSGIRequest", MockRequest):
with patch("sentry_sdk.integrations.django.DjangoRequestExtractor", MockExtractor):
client.post(
reverse("post_echo"), data=b'{"hey": 42}', content_type="application/json"
)

(event,) = events
(event,) = events

assert event["message"] == "hi"
assert "data" not in event["request"]
assert event["message"] == "hi"
assert "data" not in event["request"]


def test_template_tracing_meta(sentry_init, client, capture_events):
Expand Down

0 comments on commit 1c1a4b0

Please sign in to comment.