forked from smithy-lang/smithy-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
31 lines (26 loc) · 949 Bytes
/
utils.py
File metadata and controls
31 lines (26 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from smithy_core import URI
from smithy_http import tuples_to_fields
from smithy_http.aio import HTTPRequest
def create_test_request(
method: str = "GET",
host: str = "test.aws.dev",
path: str | None = None,
headers: list[tuple[str, str]] | None = None,
body: bytes = b"",
) -> HTTPRequest:
"""Create test HTTPRequest with defaults.
:param method: HTTP method (GET, POST, etc.)
:param host: Host name (e.g., "test.aws.dev")
:param path: Optional path (e.g., "/users")
:param headers: Optional headers as list of (name, value) tuples
:param body: Request body as bytes
:return: Configured HTTPRequest for testing
"""
return HTTPRequest(
destination=URI(host=host, path=path),
method=method,
fields=tuples_to_fields(headers or []),
body=body,
)