@@ -374,7 +374,7 @@ def test_read_request(sentry_init, client, capture_events):
374
374
375
375
event , = events
376
376
377
- assert event [ "request" ][ " data"] == { "hey" : 42 }
377
+ assert " data" not in event [ "request" ]
378
378
379
379
380
380
def test_template_exception (sentry_init , client , capture_events ):
@@ -413,12 +413,15 @@ def test_template_exception(sentry_init, client, capture_events):
413
413
]
414
414
415
415
416
+ @pytest .mark .parametrize (
417
+ "route" , ["rest_framework_exc" , "rest_framework_read_body_and_exc" ]
418
+ )
416
419
@pytest .mark .parametrize (
417
420
"type,event_request" ,
418
421
[
419
422
[
420
423
"json" ,
421
- {
424
+ lambda route : {
422
425
"cookies" : {},
423
426
"data" : {"foo" : "bar" },
424
427
"env" : {"SERVER_NAME" : "localhost" , "SERVER_PORT" : "80" },
@@ -429,12 +432,12 @@ def test_template_exception(sentry_init, client, capture_events):
429
432
},
430
433
"method" : "POST" ,
431
434
"query_string" : "" ,
432
- "url" : "http://localhost/rest-framework-exc" ,
435
+ "url" : "http://localhost/{}" . format ( route . replace ( "_" , "-" )) ,
433
436
},
434
437
],
435
438
[
436
439
"formdata" ,
437
- {
440
+ lambda route : {
438
441
"cookies" : {},
439
442
"data" : {"foo" : "bar" },
440
443
"env" : {"SERVER_NAME" : "localhost" , "SERVER_PORT" : "80" },
@@ -445,13 +448,13 @@ def test_template_exception(sentry_init, client, capture_events):
445
448
},
446
449
"method" : "POST" ,
447
450
"query_string" : "" ,
448
- "url" : "http://localhost/rest-framework-exc" ,
451
+ "url" : "http://localhost/{}" . format ( route . replace ( "_" , "-" )) ,
449
452
},
450
453
],
451
454
],
452
455
)
453
456
def test_rest_framework_basic (
454
- sentry_init , client , capture_events , capture_exceptions , type , event_request
457
+ sentry_init , client , capture_events , capture_exceptions , type , event_request , route
455
458
):
456
459
pytest .importorskip ("rest_framework" )
457
460
sentry_init (integrations = [DjangoIntegration ()], send_default_pii = True )
@@ -460,12 +463,12 @@ def test_rest_framework_basic(
460
463
461
464
if type == "json" :
462
465
client .post (
463
- reverse ("rest_framework_exc" ),
466
+ reverse (route ),
464
467
data = json .dumps ({"foo" : "bar" }),
465
468
content_type = "application/json" ,
466
469
)
467
470
elif type == "formdata" :
468
- client .post (reverse ("rest_framework_exc" ), data = {"foo" : "bar" })
471
+ client .post (reverse (route ), data = {"foo" : "bar" })
469
472
else :
470
473
assert False
471
474
@@ -475,4 +478,4 @@ def test_rest_framework_basic(
475
478
event , = events
476
479
assert event ["exception" ]["values" ][0 ]["mechanism" ]["type" ] == "django"
477
480
478
- assert event ["request" ] == event_request
481
+ assert event ["request" ] == event_request ( route )
0 commit comments