Skip to content

Commit 784462c

Browse files
committed
fix pyramid
1 parent 32a1166 commit 784462c

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

tests/integrations/pyramid/test_pyramid.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from werkzeug.test import Client
1010

1111
from sentry_sdk import capture_message, add_breadcrumb
12+
from sentry_sdk.consts import DEFAULT_MAX_VALUE_LENGTH
1213
from sentry_sdk.integrations.pyramid import PyramidIntegration
1314
from sentry_sdk.serializer import MAX_DATABAG_BREADTH
1415
from tests.conftest import unpack_werkzeug_response
@@ -156,9 +157,9 @@ def test_transaction_style(
156157

157158

158159
def test_large_json_request(sentry_init, capture_events, route, get_client):
159-
sentry_init(integrations=[PyramidIntegration()])
160+
sentry_init(integrations=[PyramidIntegration()], max_request_body_size="always")
160161

161-
data = {"foo": {"bar": "a" * 2000}}
162+
data = {"foo": {"bar": "a" * (DEFAULT_MAX_VALUE_LENGTH + 10)}}
162163

163164
@route("/")
164165
def index(request):
@@ -175,9 +176,14 @@ def index(request):
175176

176177
(event,) = events
177178
assert event["_meta"]["request"]["data"]["foo"]["bar"] == {
178-
"": {"len": 2000, "rem": [["!limit", "x", 1021, 1024]]}
179+
"": {
180+
"len": DEFAULT_MAX_VALUE_LENGTH + 10,
181+
"rem": [
182+
["!limit", "x", DEFAULT_MAX_VALUE_LENGTH - 3, DEFAULT_MAX_VALUE_LENGTH]
183+
],
184+
}
179185
}
180-
assert len(event["request"]["data"]["foo"]["bar"]) == 1024
186+
assert len(event["request"]["data"]["foo"]["bar"]) == DEFAULT_MAX_VALUE_LENGTH
181187

182188

183189
@pytest.mark.parametrize("data", [{}, []], ids=["empty-dict", "empty-list"])
@@ -230,7 +236,10 @@ def index(request):
230236
def test_files_and_form(sentry_init, capture_events, route, get_client):
231237
sentry_init(integrations=[PyramidIntegration()], max_request_body_size="always")
232238

233-
data = {"foo": "a" * 2000, "file": (BytesIO(b"hello"), "hello.txt")}
239+
data = {
240+
"foo": "a" * (DEFAULT_MAX_VALUE_LENGTH + 10),
241+
"file": (BytesIO(b"hello"), "hello.txt"),
242+
}
234243

235244
@route("/")
236245
def index(request):
@@ -244,9 +253,14 @@ def index(request):
244253

245254
(event,) = events
246255
assert event["_meta"]["request"]["data"]["foo"] == {
247-
"": {"len": 2000, "rem": [["!limit", "x", 1021, 1024]]}
256+
"": {
257+
"len": DEFAULT_MAX_VALUE_LENGTH + 10,
258+
"rem": [
259+
["!limit", "x", DEFAULT_MAX_VALUE_LENGTH - 3, DEFAULT_MAX_VALUE_LENGTH]
260+
],
261+
}
248262
}
249-
assert len(event["request"]["data"]["foo"]) == 1024
263+
assert len(event["request"]["data"]["foo"]) == DEFAULT_MAX_VALUE_LENGTH
250264

251265
assert event["_meta"]["request"]["data"]["file"] == {"": {"rem": [["!raw", "x"]]}}
252266
assert not event["request"]["data"]["file"]

0 commit comments

Comments
 (0)