"""Common test utils.""" import json from typing import Any def generate_event( path: str, method: str = 'GET', query_params: dict[str, Any] | None = None, body: dict[str, Any] | None = None, headers: dict[str, Any] | None = None, ) -> dict[str, Any]: """Generate lambda event.""" if query_params: query_params = {k: str(v) for k, v in query_params.items() if v is not None} if headers: headers = { k.replace('_', '-'): str(v) for k, v in headers.items() if v is not None } return { 'body': json.dumps(body) if body else None, 'path': path, 'httpMethod': method, 'queryStringParameters': query_params, 'headers': headers, }