@@ -433,58 +433,28 @@ def test_template_exception(sentry_init, client, capture_events):
433
433
"route" , ["rest_framework_exc" , "rest_framework_read_body_and_exc" ]
434
434
)
435
435
@pytest .mark .parametrize (
436
- "type,event_request " ,
436
+ "ct,body " ,
437
437
[
438
- [
439
- "json" ,
440
- lambda route : {
441
- "cookies" : {},
442
- "data" : {"foo" : "bar" },
443
- "env" : {"SERVER_NAME" : "localhost" , "SERVER_PORT" : "80" },
444
- "headers" : {
445
- "Content-Length" : "14" ,
446
- "Content-Type" : "application/json" ,
447
- "Host" : "localhost" ,
448
- },
449
- "method" : "POST" ,
450
- "query_string" : "" ,
451
- "url" : "http://localhost/{}" .format (route .replace ("_" , "-" )),
452
- },
453
- ],
454
- [
455
- "formdata" ,
456
- lambda route : {
457
- "cookies" : {},
458
- "data" : {"foo" : "bar" },
459
- "env" : {"SERVER_NAME" : "localhost" , "SERVER_PORT" : "80" },
460
- "headers" : {
461
- "Content-Length" : "7" ,
462
- "Content-Type" : "application/x-www-form-urlencoded" ,
463
- "Host" : "localhost" ,
464
- },
465
- "method" : "POST" ,
466
- "query_string" : "" ,
467
- "url" : "http://localhost/{}" .format (route .replace ("_" , "-" )),
468
- },
469
- ],
438
+ ["application/json" , {"foo" : "bar" }],
439
+ ["application/json" , 1 ],
440
+ ["application/json" , "foo" ],
441
+ ["application/x-www-form-urlencoded" , {"foo" : "bar" }],
470
442
],
471
443
)
472
444
def test_rest_framework_basic (
473
- sentry_init , client , capture_events , capture_exceptions , type , event_request , route
445
+ sentry_init , client , capture_events , capture_exceptions , ct , body , route
474
446
):
475
447
pytest .importorskip ("rest_framework" )
476
448
sentry_init (integrations = [DjangoIntegration ()], send_default_pii = True )
477
449
exceptions = capture_exceptions ()
478
450
events = capture_events ()
479
451
480
- if type == "json" :
452
+ if ct == "application/ json" :
481
453
client .post (
482
- reverse (route ),
483
- data = json .dumps ({"foo" : "bar" }),
484
- content_type = "application/json" ,
454
+ reverse (route ), data = json .dumps (body ), content_type = "application/json"
485
455
)
486
- elif type == "formdata " :
487
- client .post (reverse (route ), data = { "foo" : "bar" } )
456
+ elif ct == "application/x-www-form-urlencoded " :
457
+ client .post (reverse (route ), data = body )
488
458
else :
489
459
assert False
490
460
@@ -494,7 +464,8 @@ def test_rest_framework_basic(
494
464
event , = events
495
465
assert event ["exception" ]["values" ][0 ]["mechanism" ]["type" ] == "django"
496
466
497
- assert event ["request" ] == event_request (route )
467
+ assert event ["request" ]["data" ] == body
468
+ assert event ["request" ]["headers" ]["Content-Type" ] == ct
498
469
499
470
500
471
@pytest .mark .parametrize (
0 commit comments