@@ -67,6 +67,8 @@ def truncate_data(data):
6767
6868 if data["contexts"].get("trace") is not None:
6969 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()"}
7072
7173 if data.get("transaction") is not None:
7274 cleaned_data["transaction"] = data.get("transaction")
@@ -287,7 +289,8 @@ def test_handler(event, context):
287289 "X-Forwarded-Proto": "https"
288290 },
289291 "queryStringParameters": {
290- "bonkers": "true"
292+ "bonkers": "true",
293+ "wild": "false"
291294 },
292295 "pathParameters": null,
293296 "stageVariables": null,
@@ -312,7 +315,7 @@ def test_handler(event, context):
312315 "X-Forwarded-Proto" : "https" ,
313316 },
314317 "method" : "GET" ,
315- "query_string" : { "bonkers" : " true" } ,
318+ "query_string" : "bonkers= true&wild=false" ,
316319 "url" : "https://iwsz2c7uwi.execute-api.us-east-1.amazonaws.com/asd" ,
317320 }
318321
@@ -487,6 +490,15 @@ def test_handler(event, context):
487490 ),
488491 (b"[]" , False , 1 ),
489492 ],
493+ ids = [
494+ "int" ,
495+ "float" ,
496+ "string" ,
497+ "bool" ,
498+ "list" ,
499+ "list_with_request_data" ,
500+ "empty_list" ,
501+ ],
490502)
491503def test_non_dict_event (
492504 run_lambda_function ,
@@ -539,9 +551,7 @@ def test_handler(event, context):
539551 "headers" : {"Host" : "x1.io" , "X-Forwarded-Proto" : "https" },
540552 "method" : "GET" ,
541553 "url" : "https://x1.io/1" ,
542- "query_string" : {
543- "done" : "f" ,
544- },
554+ "query_string" : "done=f" ,
545555 }
546556 else :
547557 request_data = {"url" : "awslambda:///{}" .format (function_name )}
@@ -590,7 +600,7 @@ def test_traces_sampler_gets_correct_values_in_sampling_context(
590600
591601 import inspect
592602
593- _ , response = run_lambda_function (
603+ function_code = (
594604 LAMBDA_PRELUDE
595605 + dedent (inspect .getsource (StringContaining ))
596606 + dedent (inspect .getsource (DictionaryContaining ))
@@ -621,7 +631,7 @@ def test_handler(event, context):
621631 {
622632 "http.request.method": "GET",
623633 "url.path": "/sit/stay/rollover",
624- "url.query": "repeat=again ",
634+ "url.query": "repeat=twice ",
625635 "url.full": "http://x.io/sit/stay/rollover?repeat=twice",
626636 "network.protocol.name": "http",
627637 "server.address": "x.io",
@@ -643,10 +653,15 @@ def test_handler(event, context):
643653 traces_sampler=traces_sampler,
644654 )
645655 """
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+ )
648657 )
649658
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+ )
650665 assert response ["Payload" ]["AssertionError raised" ] is False
651666
652667
0 commit comments