@@ -67,6 +67,8 @@ def truncate_data(data):
67
67
68
68
if data["contexts"].get("trace") is not None:
69
69
cleaned_data["contexts"]["trace"] = data["contexts"].get("trace")
70
+ if cleaned_data["contexts"]["trace"].get("data", {}) != {}:
71
+ cleaned_data["contexts"]["trace"]["data"] = {"removed": "by truncate_data()"}
70
72
71
73
if data.get("transaction") is not None:
72
74
cleaned_data["transaction"] = data.get("transaction")
@@ -287,7 +289,8 @@ def test_handler(event, context):
287
289
"X-Forwarded-Proto": "https"
288
290
},
289
291
"queryStringParameters": {
290
- "bonkers": "true"
292
+ "bonkers": "true",
293
+ "wild": "false"
291
294
},
292
295
"pathParameters": null,
293
296
"stageVariables": null,
@@ -312,7 +315,7 @@ def test_handler(event, context):
312
315
"X-Forwarded-Proto" : "https" ,
313
316
},
314
317
"method" : "GET" ,
315
- "query_string" : { "bonkers" : " true" } ,
318
+ "query_string" : "bonkers= true&wild=false" ,
316
319
"url" : "https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd" ,
317
320
}
318
321
@@ -487,6 +490,15 @@ def test_handler(event, context):
487
490
),
488
491
(b"[]" , False , 1 ),
489
492
],
493
+ ids = [
494
+ "int" ,
495
+ "float" ,
496
+ "string" ,
497
+ "bool" ,
498
+ "list" ,
499
+ "list_with_request_data" ,
500
+ "empty_list" ,
501
+ ],
490
502
)
491
503
def test_non_dict_event (
492
504
run_lambda_function ,
@@ -539,9 +551,7 @@ def test_handler(event, context):
539
551
"headers" : {"Host" : "x1.io" , "X-Forwarded-Proto" : "https" },
540
552
"method" : "GET" ,
541
553
"url" : "https://x1.io/1" ,
542
- "query_string" : {
543
- "done" : "f" ,
544
- },
554
+ "query_string" : "done=f" ,
545
555
}
546
556
else :
547
557
request_data = {"url" : "awslambda:///{}" .format (function_name )}
@@ -590,7 +600,7 @@ def test_traces_sampler_gets_correct_values_in_sampling_context(
590
600
591
601
import inspect
592
602
593
- _ , response = run_lambda_function (
603
+ function_code = (
594
604
LAMBDA_PRELUDE
595
605
+ dedent (inspect .getsource (StringContaining ))
596
606
+ dedent (inspect .getsource (DictionaryContaining ))
@@ -621,7 +631,7 @@ def test_handler(event, context):
621
631
{
622
632
"http.request.method": "GET",
623
633
"url.path": "/sit/stay/rollover",
624
- "url.query": "repeat=again ",
634
+ "url.query": "repeat=twice ",
625
635
"url.full": "http://x.io/sit/stay/rollover?repeat=twice",
626
636
"network.protocol.name": "http",
627
637
"server.address": "x.io",
@@ -643,10 +653,15 @@ def test_handler(event, context):
643
653
traces_sampler=traces_sampler,
644
654
)
645
655
"""
646
- ),
647
- b'{"httpMethod": "GET", "path": "/sit/stay/rollover", "query_string": {"repeat": "again"}, "headers": {"Host": "x.io", "X-Forwarded-Proto": "http", "Custom-Header": "Custom Value"}}' ,
656
+ )
648
657
)
649
658
659
+ payload = b'{"httpMethod": "GET", "path": "/sit/stay/rollover", "queryStringParameters": {"repeat": "twice"}, "headers": {"Host": "x.io", "X-Forwarded-Proto": "http", "Custom-Header": "Custom Value"}}'
660
+
661
+ _ , response = run_lambda_function (
662
+ code = function_code ,
663
+ payload = payload ,
664
+ )
650
665
assert response ["Payload" ]["AssertionError raised" ] is False
651
666
652
667
0 commit comments