@@ -50,7 +50,6 @@ def test_environment():
5050
5151 def before_test ():
5252 server .clear_envelopes ()
53- print ("[TEST] Clearing envelopes before test" )
5453
5554 yield {
5655 "stack" : stack ,
@@ -87,27 +86,81 @@ def lambda_client():
8786 )
8887
8988
90- def test_basic (lambda_client , test_environment ):
91- response = lambda_client .invoke (
92- FunctionName = "BasicTestFunction" , Payload = json .dumps ({"name" : "Ivana" })
93- )
94- result = json .loads (response ["Payload" ].read ().decode ())
95- assert result == {"message" : "Hello, Ivana!" }
89+ # def test_basic_ok(lambda_client, test_environment):
90+ # response = lambda_client.invoke(
91+ # FunctionName="BasicOk",
92+ # Payload=json.dumps({"name": "Ivana"}),
93+ # )
94+ # result = json.loads(response["Payload"].read().decode())
95+ # assert result == {"event": {"name": "Ivana"}}
9696
97- message , transaction = test_environment ["server" ].envelopes
98- assert message ["message" ] == "[SENTRY MESSAGE] Hello, Ivana!"
99- assert transaction ["type" ] == "transaction"
97+ # envelopes = test_environment["server"].envelopes
98+ # assert len(envelopes) == 1
10099
100+ # transaction = envelopes[0]
101+ # assert transaction["type"] == "transaction"
101102
102- def test_basic_2 (lambda_client , test_environment ):
103- test_environment ["server" ].clear_envelopes ()
104103
105- response = lambda_client .invoke (
106- FunctionName = "BasicTestFunction" , Payload = json .dumps ({"name" : "Neel" })
107- )
108- result = json .loads (response ["Payload" ].read ().decode ())
109- assert result == {"message" : "Hello, Neel!" }
104+ def test_xxx (lambda_client , test_environment ):
105+ for x in range (20 ):
106+ test_environment ["server" ].clear_envelopes ()
107+ print (f"*** BasicException { x } ***" )
108+ response = lambda_client .invoke (
109+ FunctionName = "BasicException" ,
110+ Payload = json .dumps ({}),
111+ )
112+ print ("- RESPONSE" )
113+ print (response )
114+ print ("- PAYLOAD" )
115+ print (response ["Payload" ].read ().decode ())
116+ print (f'- ENVELOPES { len (test_environment ["server" ].envelopes )} ' )
117+
118+
119+
120+ assert False
121+
122+
123+ # def test_basic(lambda_client, test_environment):
124+ # response = lambda_client.invoke(
125+ # FunctionName="BasicException",
126+ # Payload=json.dumps({"name": "Neel"}),
127+ # )
128+ # print("RESPONSE")
129+ # print(response)
130+ # print("PAYLOAD")
131+ # print(response["Payload"].read().decode())
132+ # result = json.loads(response["Payload"].read().decode())
133+ # print("RESULT")
134+ # print(result)
135+
136+ # envelopes = test_environment["server"].envelopes
137+ # (error,) = envelopes
138+
139+ # assert error["level"] == "error"
140+ # (exception,) = error["exception"]["values"]
141+ # assert exception["type"] == "Exception"
142+ # assert exception["value"] == "Oh!"
143+
144+ # (frame1,) = exception["stacktrace"]["frames"]
145+ # assert frame1["filename"] == "test_lambda.py"
146+ # assert frame1["abs_path"] == "/var/task/test_lambda.py"
147+ # assert frame1["function"] == "test_handler"
148+
149+ # assert frame1["in_app"] is True
150+
151+ # assert exception["mechanism"]["type"] == "aws_lambda"
152+ # assert not exception["mechanism"]["handled"]
153+
154+ # assert error["extra"]["lambda"]["function_name"].startswith("test_")
155+
156+ # logs_url = error["extra"]["cloudwatch logs"]["url"]
157+ # assert logs_url.startswith("https://console.aws.amazon.com/cloudwatch/home?region")
158+ # assert not re.search("(=;|=$)", logs_url)
159+ # assert error["extra"]["cloudwatch logs"]["log_group"].startswith(
160+ # "/aws/lambda/test_"
161+ # )
162+
163+ # log_stream_re = "^[0-9]{4}/[0-9]{2}/[0-9]{2}/\\[[^\\]]+][a-f0-9]+$"
164+ # log_stream = error["extra"]["cloudwatch logs"]["log_stream"]
110165
111- message , transaction = test_environment ["server" ].envelopes
112- assert message ["message" ] == "[SENTRY MESSAGE] Hello, Neel!"
113- assert transaction ["type" ] == "transaction"
166+ # assert re.match(log_stream_re, log_stream)
0 commit comments