File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ import asyncio
1
2
import datetime
2
3
import json
3
4
import os
@@ -126,6 +127,43 @@ def test_resolver_value_error():
126
127
assert exp .value .args [0 ] == "No resolver found for 'type.field'"
127
128
128
129
130
+ def test_resolver_yield ():
131
+ # GIVEN
132
+ app = AppSyncResolver ()
133
+
134
+ mock_event = {"typeName" : "Customer" , "fieldName" : "field" , "arguments" : {}}
135
+
136
+ @app .resolver (field_name = "field" )
137
+ def func_yield ():
138
+ yield "value"
139
+
140
+ # WHEN
141
+ mock_context = LambdaContext ()
142
+ result = app .resolve (mock_event , mock_context )
143
+
144
+ # THEN
145
+ assert next (result ) == "value"
146
+
147
+
148
+ def test_resolver_async ():
149
+ # GIVEN
150
+ app = AppSyncResolver ()
151
+
152
+ mock_event = {"typeName" : "Customer" , "fieldName" : "field" , "arguments" : {}}
153
+
154
+ @app .resolver (field_name = "field" )
155
+ async def get_async ():
156
+ await asyncio .sleep (0.0001 )
157
+ return "value"
158
+
159
+ # WHEN
160
+ mock_context = LambdaContext ()
161
+ result = app .resolve (mock_event , mock_context )
162
+
163
+ # THEN
164
+ assert asyncio .run (result ) == "value"
165
+
166
+
129
167
def test_make_id ():
130
168
uuid : str = make_id ()
131
169
assert isinstance (uuid , str )
You can’t perform that action at this time.
0 commit comments