Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Util for single invokation. #9

Open
pkucmus opened this issue Apr 27, 2024 · 0 comments
Open

Util for single invokation. #9

pkucmus opened this issue Apr 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@pkucmus
Copy link
Contributor

pkucmus commented Apr 27, 2024

Would be nice if Smyth provided a tool to mock a singular request. Instead of running the uvicorn server, allow to invoke the handler, i.e. generate the event and context - invoke the handler and exit.
This contradicts what Smyth is about but still I'm running into debugging cases where it would be useful to just invoke the handler function.

Right now one can do:

event = {
    "version": "2.0",
    "rawPath": "/",
    "body": "",
    "isBase64Encoded": False,
    "headers": {},
    "queryStringParameters": {},
    "requestContext": {
        "http": {
            "method": "GET",
            "path": "/",
            "protocol": "http",
            "sourceIp": "127.0.0.1",
        },
        "routeKey": "POST /",
        "accountId": "offlineContext_accountId",
        "stage": "$default",
    },
    "routeKey": "POST /",
    "rawQueryString": "",
}

if __name__ == "__main__":
    print(handler(event, {}))

Instead I would like to:

python -m smyth invoke {my_handler}
@pkucmus pkucmus added the enhancement New feature or request label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant