2121from nitric .faas import Response , ResponseContext , HttpResponseContext
2222from nitric .faas import start
2323from nitric .faas .faas import Handler
24- from nitric .proto .faas .v1 .faas_pb2 import TriggerResponse
24+ from nitric .proto .faas .v1 .faas_pb2 import TriggerResponse , TriggerRequest
2525from google .protobuf import json_format
2626
2727
@@ -50,7 +50,10 @@ def test_full_response(self):
5050
5151 return_body = json_format .MessageToJson (mock_response .to_grpc_trigger_response_context ())
5252
53- with patch ("nitric.faas.faas.construct_request" , Mock ()):
53+ construct_request_mock = Mock ()
54+ construct_request_mock .return_value = TriggerRequest ()
55+
56+ with patch ("nitric.faas.faas.construct_request" , construct_request_mock ):
5457 handler = Handler (mock_func )
5558 response = handler ()
5659
@@ -62,7 +65,10 @@ def test_unhandled_exception(self):
6265 def error_func ():
6366 raise Exception ("mock error" )
6467
65- with patch ("nitric.faas.faas.construct_request" , Mock ()):
68+ construct_request_mock = Mock ()
69+ construct_request_mock .return_value = TriggerRequest ()
70+
71+ with patch ("nitric.faas.faas.construct_request" , construct_request_mock ):
6672 handler = Handler (error_func )
6773 response = handler ()
6874
@@ -78,7 +84,10 @@ def test_debug_unhandled_exception(self):
7884 def error_func ():
7985 raise Exception ("mock error" )
8086
81- with patch ("nitric.faas.faas.construct_request" , Mock ()):
87+ construct_request_mock = Mock ()
88+ construct_request_mock .return_value = TriggerRequest ()
89+
90+ with patch ("nitric.faas.faas.construct_request" , construct_request_mock ):
8291 handler = Handler (error_func )
8392 response = handler ()
8493
@@ -94,7 +103,10 @@ def test_str_response(self):
94103 mock_func = Mock ()
95104 mock_func .return_value = "test"
96105
97- with patch ("nitric.faas.faas.construct_request" , Mock ()):
106+ construct_request_mock = Mock ()
107+ construct_request_mock .return_value = TriggerRequest ()
108+
109+ with patch ("nitric.faas.faas.construct_request" , construct_request_mock ):
98110 handler = Handler (mock_func )
99111 response = handler ()
100112
@@ -109,7 +121,10 @@ def no_response(request):
109121 # do nothing
110122 mock = Mock ()
111123
112- with patch ("nitric.faas.faas.construct_request" , Mock ()):
124+ construct_request_mock = Mock ()
125+ construct_request_mock .return_value = TriggerRequest ()
126+
127+ with patch ("nitric.faas.faas.construct_request" , construct_request_mock ):
113128 handler = Handler (no_response )
114129 response = handler ()
115130
0 commit comments