import base64 from urllib.parse import urlencode from app.models import Event def _encode_body(params: dict[str, str]) -> str: return base64.b64encode(urlencode(params).encode()).decode() def test_event_decoding_and_props() -> None: body_params = { "Body": " HeLLo ", "From": "+14155552671", "To": "+12125551234", } event_dict = { "path": "/inbound", "headers": { "x-twilio-signature": "sig", "host": "example.com", "x-forwarded-proto": "https", }, "body": _encode_body(body_params), "queryStringParameters": {"b": "2", "a": "1"}, } event = Event.model_validate(event_dict) assert event.request_full_uri.endswith("?a=1&b=2")