Skip to content

Commit cab6d60

Browse files
committed
chore: add functional tests
1 parent 09d6bff commit cab6d60

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/functional/event_handler/test_appsync.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,26 @@ async def get_async():
138138

139139
# THEN
140140
assert asyncio.run(result) == "value"
141+
142+
143+
def test_resolve_custom_model():
144+
# Check whether we can handle an example appsync direct resolver
145+
mock_event = load_event("appSyncDirectResolver.json")
146+
147+
class MyCustomModel(AppSyncResolverEvent):
148+
@property
149+
def country_viewer(self):
150+
return self.request_headers.get("cloudfront-viewer-country")
151+
152+
app = AppSyncResolver()
153+
154+
@app.resolver(field_name="createSomething")
155+
def create_something(id: str): # noqa AA03 VNE003
156+
return id
157+
158+
# Call the implicit handler
159+
result = app(event=mock_event, context=LambdaContext(), model=MyCustomModel)
160+
161+
assert result == "my identifier"
162+
163+
assert app.current_event.country_viewer == "US"

0 commit comments

Comments
 (0)