Skip to content

Instantly share code, notes, and snippets.

@to-mc
Last active February 3, 2022 15:13
Show Gist options
  • Save to-mc/57779035717cf0909b97c28c1d34caff to your computer and use it in GitHub Desktop.
Save to-mc/57779035717cf0909b97c28c1d34caff to your computer and use it in GitHub Desktop.
@pytest.mark.asyncio
async def test_resolver_async():
# GIVEN
app = AppSyncResolver()
mock_event = {"typeName": "Customer", "fieldName": "field", "arguments": {}}
# Note: this function would be defined in another module in an actual serverless application, and imported.
# Its structured this way here as we're testing the framework itself.
@app.resolver(field_name="field")
async def get_async():
await asyncio.sleep(0.0001)
return "value"
# WHEN
mock_context = LambdaContext()
result = await app.resolve(mock_event, mock_context)
# THEN
assert result == "value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment