From 34f556a2fe0b1331616d7462afe0a0ec077204f8 Mon Sep 17 00:00:00 2001 From: Alessandra Romero Date: Tue, 21 Oct 2025 17:36:00 -0400 Subject: [PATCH 1/2] Add smithy-testing package for functional testing --- ...smithy-testing-feature-20251021153329.json | 4 + packages/smithy-testing/NOTICE | 1 + packages/smithy-testing/README.md | 40 ++++++ packages/smithy-testing/pyproject.toml | 53 ++++++++ .../src/smithy_testing/__init__.py | 15 +++ .../smithy-testing/src/smithy_testing/http.py | 89 ++++++++++++++ .../src/smithy_testing/py.typed | 0 .../src/smithy_testing/utils.py | 30 +++++ packages/smithy-testing/tests/__init__.py | 2 + packages/smithy-testing/tests/py.typed | 0 .../smithy-testing/tests/unit/__init__.py | 2 + .../tests/unit/test_mock_http_client.py | 114 ++++++++++++++++++ .../smithy-testing/tests/unit/test_utils.py | 42 +++++++ pyproject.toml | 1 + uv.lock | 15 +++ 15 files changed, 408 insertions(+) create mode 100644 packages/smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json create mode 100644 packages/smithy-testing/NOTICE create mode 100644 packages/smithy-testing/README.md create mode 100644 packages/smithy-testing/pyproject.toml create mode 100644 packages/smithy-testing/src/smithy_testing/__init__.py create mode 100644 packages/smithy-testing/src/smithy_testing/http.py create mode 100644 packages/smithy-testing/src/smithy_testing/py.typed create mode 100644 packages/smithy-testing/src/smithy_testing/utils.py create mode 100644 packages/smithy-testing/tests/__init__.py create mode 100644 packages/smithy-testing/tests/py.typed create mode 100644 packages/smithy-testing/tests/unit/__init__.py create mode 100644 packages/smithy-testing/tests/unit/test_mock_http_client.py create mode 100644 packages/smithy-testing/tests/unit/test_utils.py diff --git a/packages/smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json b/packages/smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json new file mode 100644 index 000000000..846f6e4b8 --- /dev/null +++ b/packages/smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json @@ -0,0 +1,4 @@ +{ + "type": "feature", + "description": "Added support for minimal components required for SDK functional testing" +} \ No newline at end of file diff --git a/packages/smithy-testing/NOTICE b/packages/smithy-testing/NOTICE new file mode 100644 index 000000000..616fc5889 --- /dev/null +++ b/packages/smithy-testing/NOTICE @@ -0,0 +1 @@ +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/smithy-testing/README.md b/packages/smithy-testing/README.md new file mode 100644 index 000000000..fa0695186 --- /dev/null +++ b/packages/smithy-testing/README.md @@ -0,0 +1,40 @@ +# smithy-testing + +This package provides shared utilities for testing functionality in tooling generated by Smithy. + +--- + +## MockHTTPClient + +The `MockHTTPClient` allows you to test smithy-python clients without making actual network calls. It implements the `HTTPClient` interface and provides configurable responses for functional testing. + +### Basic Usage + +```python +from smithy_testing import MockHTTPClient + +# Create mock client and configure responses +mock_client = MockHTTPClient() +mock_client.add_response( + status=200, + headers=[("Content-Type", "application/json")], + body=b'{"message": "success"}' +) + +# Use with your smithy-python client +config = Config(transport=mock_client) +client = TestSmithyServiceClient(config=config) + +# Test your client logic +result = await client.some_operation({"input": "data"}) + +# Inspect what requests were made +assert mock_client.call_count == 1 +captured_request = mock_client.captured_requests[0] +assert result.message == "success" +``` + +## Utilities + +- `create_test_request()`: Helper for creating test HTTPRequest objects +- `MockHTTPClientError`: Exception raised when no responses are queued diff --git a/packages/smithy-testing/pyproject.toml b/packages/smithy-testing/pyproject.toml new file mode 100644 index 000000000..f1bda8df9 --- /dev/null +++ b/packages/smithy-testing/pyproject.toml @@ -0,0 +1,53 @@ +[project] +name = "smithy-testing" +dynamic = ["version"] +requires-python = ">=3.12" +authors = [ + {name = "Amazon Web Services"}, +] +description = "Core components for testing Smithy tooling in Python." +readme = "README.md" +license = {text = "Apache License 2.0"} +keywords = ["smithy", "sdk"] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Natural Language :: English", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development :: Libraries" +] +dependencies = [] + +[project.urls] +"Changelog" = "https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-testing/CHANGELOG.md" +"Code" = "https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-testing/" +"Issue tracker" = "https://github.com/smithy-lang/smithy-python/issues" + +[dependency-groups] +typing = [ + "typing_extensions>=4.13.0", +] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.version] +path = "src/smithy_testing/__init__.py" + +[tool.hatch.build] +exclude = [ + "tests", +] + +[tool.ruff] +src = ["src"] diff --git a/packages/smithy-testing/src/smithy_testing/__init__.py b/packages/smithy-testing/src/smithy_testing/__init__.py new file mode 100644 index 000000000..fe4f80856 --- /dev/null +++ b/packages/smithy-testing/src/smithy_testing/__init__.py @@ -0,0 +1,15 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Shared testing utilities for smithy-python functional tests.""" + +from .http import MockHTTPClient, MockHTTPClientError +from .utils import create_test_request + +__version__ = "0.0.0" + +__all__ = ( + "MockHTTPClient", + "MockHTTPClientError", + "create_test_request", +) diff --git a/packages/smithy-testing/src/smithy_testing/http.py b/packages/smithy-testing/src/smithy_testing/http.py new file mode 100644 index 000000000..f66c5a98f --- /dev/null +++ b/packages/smithy-testing/src/smithy_testing/http.py @@ -0,0 +1,89 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +from collections import deque +from copy import copy + +from smithy_core.aio.utils import async_list +from smithy_http import tuples_to_fields +from smithy_http.aio import HTTPResponse +from smithy_http.aio.interfaces import HTTPClient, HTTPRequest +from smithy_http.interfaces import HTTPClientConfiguration, HTTPRequestConfiguration + + +class MockHTTPClient(HTTPClient): + """Implementation of :py:class:`.interfaces.HTTPClient` solely for testing purposes. + + Simulates HTTP request/response behavior. + Responses are queued in FIFO order and requests are captured for inspection. + """ + + def __init__( + self, + *, + client_config: HTTPClientConfiguration | None = None, + ) -> None: + """ + :param client_config: Configuration that applies to all requests made with this + client. + """ + self._client_config = client_config + self._response_queue: deque[HTTPResponse] = deque() + self._captured_requests: list[HTTPRequest] = [] + + def add_response( + self, + status: int = 200, + headers: list[tuple[str, str]] | None = None, + body: bytes = b"", + ) -> None: + """Queue a response for the next request. + + :param status: HTTP status code (200, 404, 500, etc.) + :param headers: HTTP response headers as list of (name, value) tuples + :param body: Response body as bytes + """ + response = HTTPResponse( + status=status, + fields=tuples_to_fields(headers or []), + body=async_list([body]), + reason=None, + ) + self._response_queue.append(response) + + async def send( + self, + request: HTTPRequest, + *, + request_config: HTTPRequestConfiguration | None = None, + ) -> HTTPResponse: + """Send HTTP request and return configured response. + + :param request: The request including destination URI, fields, payload. + :param request_config: Configuration specific to this request. + :returns: Pre-configured HTTP response from the queue. + :raises MockHTTPClientError: If no responses are queued. + """ + self._captured_requests.append(copy(request)) + + # Return next queued response or raise error + if self._response_queue: + return self._response_queue.popleft() + else: + raise MockHTTPClientError( + "No responses queued in MockHTTPClient. Use add_response() to queue responses." + ) + + @property + def call_count(self) -> int: + """The number of requests made to this client.""" + return len(self._captured_requests) + + @property + def captured_requests(self) -> list[HTTPRequest]: + """The list of all requests captured by this client.""" + return self._captured_requests.copy() + + +class MockHTTPClientError(Exception): + """Exception raised by MockHTTPClient for test setup issues.""" diff --git a/packages/smithy-testing/src/smithy_testing/py.typed b/packages/smithy-testing/src/smithy_testing/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/packages/smithy-testing/src/smithy_testing/utils.py b/packages/smithy-testing/src/smithy_testing/utils.py new file mode 100644 index 000000000..ff41fb592 --- /dev/null +++ b/packages/smithy-testing/src/smithy_testing/utils.py @@ -0,0 +1,30 @@ +# 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, + ) diff --git a/packages/smithy-testing/tests/__init__.py b/packages/smithy-testing/tests/__init__.py new file mode 100644 index 000000000..04f8b7b76 --- /dev/null +++ b/packages/smithy-testing/tests/__init__.py @@ -0,0 +1,2 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 diff --git a/packages/smithy-testing/tests/py.typed b/packages/smithy-testing/tests/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/packages/smithy-testing/tests/unit/__init__.py b/packages/smithy-testing/tests/unit/__init__.py new file mode 100644 index 000000000..04f8b7b76 --- /dev/null +++ b/packages/smithy-testing/tests/unit/__init__.py @@ -0,0 +1,2 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 diff --git a/packages/smithy-testing/tests/unit/test_mock_http_client.py b/packages/smithy-testing/tests/unit/test_mock_http_client.py new file mode 100644 index 000000000..4ea0bf1b0 --- /dev/null +++ b/packages/smithy-testing/tests/unit/test_mock_http_client.py @@ -0,0 +1,114 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +import pytest +from smithy_testing import MockHTTPClient, MockHTTPClientError, create_test_request + + +async def test_default_response(): + # Test error when no responses are queued + mock_client = MockHTTPClient() + request = create_test_request() + + with pytest.raises(MockHTTPClientError, match="No responses queued"): + await mock_client.send(request) + + +async def test_queued_responses_fifo(): + # Test responses are returned in FIFO order + mock_client = MockHTTPClient() + mock_client.add_response(status=404, body=b"not found") + mock_client.add_response(status=500, body=b"server error") + + request = create_test_request() + + response1 = await mock_client.send(request) + assert response1.status == 404 + assert await response1.consume_body_async() == b"not found" + + response2 = await mock_client.send(request) + assert response2.status == 500 + assert await response2.consume_body_async() == b"server error" + + assert mock_client.call_count == 2 + + +async def test_captures_requests(): + # Test all requests are captured for inspection + mock_client = MockHTTPClient() + mock_client.add_response() + mock_client.add_response() + + request1 = create_test_request( + method="GET", + host="test.aws.dev", + ) + request2 = create_test_request( + method="POST", + host="test.aws.dev", + body=b'{"name": "test"}', + ) + + await mock_client.send(request1) + await mock_client.send(request2) + + captured = mock_client.captured_requests + assert len(captured) == 2 + assert captured[0].method == "GET" + assert captured[1].method == "POST" + assert captured[1].body == b'{"name": "test"}' + + +async def test_response_headers(): + # Test response headers are properly set + mock_client = MockHTTPClient() + mock_client.add_response( + status=201, + headers=[ + ("Content-Type", "application/json"), + ("X-Amz-Custom", "test"), + ], + body=b'{"id": 123}', + ) + request = create_test_request() + response = await mock_client.send(request) + + assert response.status == 201 + assert "Content-Type" in response.fields + assert response.fields["Content-Type"].as_string() == "application/json" + assert response.fields["X-Amz-Custom"].as_string() == "test" + + +async def test_call_count_tracking(): + # Test call count is tracked correctly + mock_client = MockHTTPClient() + mock_client.add_response() + mock_client.add_response() + + request = create_test_request() + + assert mock_client.call_count == 0 + + await mock_client.send(request) + assert mock_client.call_count == 1 + + await mock_client.send(request) + assert mock_client.call_count == 2 + + +async def test_captured_requests_copy(): + # Test that captured_requests returns a copy to prevent modifications + mock_client = MockHTTPClient() + mock_client.add_response() + + request = create_test_request() + + await mock_client.send(request) + + captured1 = mock_client.captured_requests + captured2 = mock_client.captured_requests + + # Should be different list objects + assert captured1 is not captured2 + # But with same content + assert len(captured1) == len(captured2) == 1 diff --git a/packages/smithy-testing/tests/unit/test_utils.py b/packages/smithy-testing/tests/unit/test_utils.py new file mode 100644 index 000000000..dc407126f --- /dev/null +++ b/packages/smithy-testing/tests/unit/test_utils.py @@ -0,0 +1,42 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +from smithy_testing import create_test_request + + +def test_create_test_request_defaults(): + request = create_test_request() + + assert request.method == "GET" + assert request.destination.host == "test.aws.dev" + assert request.destination.path is None + assert request.body == b"" + assert len(request.fields) == 0 + + +def test_create_test_request_custom_values(): + request = create_test_request( + method="POST", + host="api.example.com", + path="/users", + headers=[ + ("Content-Type", "application/json"), + ("Authorization", "AWS4-HMAC-SHA256"), + ], + body=b'{"name": "test"}', + ) + + assert request.method == "POST" + assert request.destination.host == "api.example.com" + assert request.destination.path == "/users" + assert request.body == b'{"name": "test"}' + + assert "Content-Type" in request.fields + assert request.fields["Content-Type"].as_string() == "application/json" + assert "Authorization" in request.fields + assert request.fields["Authorization"].as_string() == "AWS4-HMAC-SHA256" + + +def test_create_test_request_empty_headers(): + request = create_test_request(headers=[]) + assert len(request.fields) == 0 diff --git a/pyproject.toml b/pyproject.toml index d7a23d99e..1078e8b27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ smithy_json = { workspace = true } smithy_aws_core = { workspace = true } smithy_aws_event_stream = { workspace = true } aws_sdk_signers = {workspace = true } +smithy_testing = { workspace = true } [tool.pyright] typeCheckingMode = "strict" diff --git a/uv.lock b/uv.lock index 3bf8fb831..dde32275d 100644 --- a/uv.lock +++ b/uv.lock @@ -11,6 +11,7 @@ members = [ "smithy-http", "smithy-json", "smithy-python", + "smithy-testing", ] [[package]] @@ -730,6 +731,20 @@ test = [ ] typing = [{ name = "pyright", specifier = ">=1.1.400" }] +[[package]] +name = "smithy-testing" +source = { editable = "packages/smithy-testing" } + +[package.dev-dependencies] +typing = [ + { name = "typing-extensions" }, +] + +[package.metadata] + +[package.metadata.requires-dev] +typing = [{ name = "typing-extensions", specifier = ">=4.13.0" }] + [[package]] name = "typing-extensions" version = "4.13.2" From 0557a6649225b2ce5764b88120c8cfeccba241cb Mon Sep 17 00:00:00 2001 From: Alessandra Romero Date: Fri, 24 Oct 2025 14:46:47 -0400 Subject: [PATCH 2/2] Move testing utilities from smithy-testing to smithy-http package --- .../smithy-http-feature-20251024135122.json} | 0 packages/smithy-http/README.md | 41 ++++++++++++++ .../src/smithy_http/testing}/__init__.py | 4 +- .../src/smithy_http/testing/mockhttp.py} | 1 + .../src/smithy_http/testing}/utils.py | 1 + .../tests/unit/testing/test_mockhttp.py} | 2 +- .../tests/unit/testing}/test_utils.py | 2 +- packages/smithy-testing/NOTICE | 1 - packages/smithy-testing/README.md | 40 -------------- packages/smithy-testing/pyproject.toml | 53 ------------------- .../src/smithy_testing/py.typed | 0 packages/smithy-testing/tests/__init__.py | 2 - packages/smithy-testing/tests/py.typed | 0 .../smithy-testing/tests/unit/__init__.py | 2 - pyproject.toml | 1 - uv.lock | 15 ------ 16 files changed, 47 insertions(+), 118 deletions(-) rename packages/{smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json => smithy-http/.changes/next-release/smithy-http-feature-20251024135122.json} (100%) rename packages/{smithy-testing/src/smithy_testing => smithy-http/src/smithy_http/testing}/__init__.py (68%) rename packages/{smithy-testing/src/smithy_testing/http.py => smithy-http/src/smithy_http/testing/mockhttp.py} (99%) rename packages/{smithy-testing/src/smithy_testing => smithy-http/src/smithy_http/testing}/utils.py (99%) rename packages/{smithy-testing/tests/unit/test_mock_http_client.py => smithy-http/tests/unit/testing/test_mockhttp.py} (97%) rename packages/{smithy-testing/tests/unit => smithy-http/tests/unit/testing}/test_utils.py (96%) delete mode 100644 packages/smithy-testing/NOTICE delete mode 100644 packages/smithy-testing/README.md delete mode 100644 packages/smithy-testing/pyproject.toml delete mode 100644 packages/smithy-testing/src/smithy_testing/py.typed delete mode 100644 packages/smithy-testing/tests/__init__.py delete mode 100644 packages/smithy-testing/tests/py.typed delete mode 100644 packages/smithy-testing/tests/unit/__init__.py diff --git a/packages/smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json b/packages/smithy-http/.changes/next-release/smithy-http-feature-20251024135122.json similarity index 100% rename from packages/smithy-testing/.changes/next-release/smithy-testing-feature-20251021153329.json rename to packages/smithy-http/.changes/next-release/smithy-http-feature-20251024135122.json diff --git a/packages/smithy-http/README.md b/packages/smithy-http/README.md index fe7edd994..8b797f423 100644 --- a/packages/smithy-http/README.md +++ b/packages/smithy-http/README.md @@ -1,3 +1,44 @@ # smithy-http This package provides primitives and interfaces for http functionality in tooling generated by Smithy. + +--- + +## Testing + +The `smithy_http.testing` module provides shared utilities for testing HTTP functionality in smithy-python clients. + +### MockHTTPClient + +The `MockHTTPClient` allows you to test smithy-python clients without making actual network calls. It implements the `HTTPClient` interface and provides configurable responses for functional testing. + +#### Basic Usage + +```python +from smithy_http.testing import MockHTTPClient + +# Create mock client and configure responses +mock_client = MockHTTPClient() +mock_client.add_response( + status=200, + headers=[("Content-Type", "application/json")], + body=b'{"message": "success"}' +) + +# Use with your smithy-python client +config = Config(transport=mock_client) +client = TestSmithyServiceClient(config=config) + +# Test your client logic +result = await client.some_operation({"input": "data"}) + +# Inspect what requests were made +assert mock_client.call_count == 1 +captured_request = mock_client.captured_requests[0] +assert result.message == "success" +``` + +### Utilities + +- `create_test_request()`: Helper for creating test HTTPRequest objects +- `MockHTTPClientError`: Exception raised when no responses are queued diff --git a/packages/smithy-testing/src/smithy_testing/__init__.py b/packages/smithy-http/src/smithy_http/testing/__init__.py similarity index 68% rename from packages/smithy-testing/src/smithy_testing/__init__.py rename to packages/smithy-http/src/smithy_http/testing/__init__.py index fe4f80856..bbc9b9af1 100644 --- a/packages/smithy-testing/src/smithy_testing/__init__.py +++ b/packages/smithy-http/src/smithy_http/testing/__init__.py @@ -1,9 +1,9 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -"""Shared testing utilities for smithy-python functional tests.""" +"""Shared utilities for smithy-python functional tests.""" -from .http import MockHTTPClient, MockHTTPClientError +from .mockhttp import MockHTTPClient, MockHTTPClientError from .utils import create_test_request __version__ = "0.0.0" diff --git a/packages/smithy-testing/src/smithy_testing/http.py b/packages/smithy-http/src/smithy_http/testing/mockhttp.py similarity index 99% rename from packages/smithy-testing/src/smithy_testing/http.py rename to packages/smithy-http/src/smithy_http/testing/mockhttp.py index f66c5a98f..956369095 100644 --- a/packages/smithy-testing/src/smithy_testing/http.py +++ b/packages/smithy-http/src/smithy_http/testing/mockhttp.py @@ -5,6 +5,7 @@ from copy import copy from smithy_core.aio.utils import async_list + from smithy_http import tuples_to_fields from smithy_http.aio import HTTPResponse from smithy_http.aio.interfaces import HTTPClient, HTTPRequest diff --git a/packages/smithy-testing/src/smithy_testing/utils.py b/packages/smithy-http/src/smithy_http/testing/utils.py similarity index 99% rename from packages/smithy-testing/src/smithy_testing/utils.py rename to packages/smithy-http/src/smithy_http/testing/utils.py index ff41fb592..9ed3a6476 100644 --- a/packages/smithy-testing/src/smithy_testing/utils.py +++ b/packages/smithy-http/src/smithy_http/testing/utils.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 from smithy_core import URI + from smithy_http import tuples_to_fields from smithy_http.aio import HTTPRequest diff --git a/packages/smithy-testing/tests/unit/test_mock_http_client.py b/packages/smithy-http/tests/unit/testing/test_mockhttp.py similarity index 97% rename from packages/smithy-testing/tests/unit/test_mock_http_client.py rename to packages/smithy-http/tests/unit/testing/test_mockhttp.py index 4ea0bf1b0..2dd48d5c8 100644 --- a/packages/smithy-testing/tests/unit/test_mock_http_client.py +++ b/packages/smithy-http/tests/unit/testing/test_mockhttp.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 import pytest -from smithy_testing import MockHTTPClient, MockHTTPClientError, create_test_request +from smithy_http.testing import MockHTTPClient, MockHTTPClientError, create_test_request async def test_default_response(): diff --git a/packages/smithy-testing/tests/unit/test_utils.py b/packages/smithy-http/tests/unit/testing/test_utils.py similarity index 96% rename from packages/smithy-testing/tests/unit/test_utils.py rename to packages/smithy-http/tests/unit/testing/test_utils.py index dc407126f..65bcbf75d 100644 --- a/packages/smithy-testing/tests/unit/test_utils.py +++ b/packages/smithy-http/tests/unit/testing/test_utils.py @@ -1,7 +1,7 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 -from smithy_testing import create_test_request +from smithy_http.testing import create_test_request def test_create_test_request_defaults(): diff --git a/packages/smithy-testing/NOTICE b/packages/smithy-testing/NOTICE deleted file mode 100644 index 616fc5889..000000000 --- a/packages/smithy-testing/NOTICE +++ /dev/null @@ -1 +0,0 @@ -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/smithy-testing/README.md b/packages/smithy-testing/README.md deleted file mode 100644 index fa0695186..000000000 --- a/packages/smithy-testing/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# smithy-testing - -This package provides shared utilities for testing functionality in tooling generated by Smithy. - ---- - -## MockHTTPClient - -The `MockHTTPClient` allows you to test smithy-python clients without making actual network calls. It implements the `HTTPClient` interface and provides configurable responses for functional testing. - -### Basic Usage - -```python -from smithy_testing import MockHTTPClient - -# Create mock client and configure responses -mock_client = MockHTTPClient() -mock_client.add_response( - status=200, - headers=[("Content-Type", "application/json")], - body=b'{"message": "success"}' -) - -# Use with your smithy-python client -config = Config(transport=mock_client) -client = TestSmithyServiceClient(config=config) - -# Test your client logic -result = await client.some_operation({"input": "data"}) - -# Inspect what requests were made -assert mock_client.call_count == 1 -captured_request = mock_client.captured_requests[0] -assert result.message == "success" -``` - -## Utilities - -- `create_test_request()`: Helper for creating test HTTPRequest objects -- `MockHTTPClientError`: Exception raised when no responses are queued diff --git a/packages/smithy-testing/pyproject.toml b/packages/smithy-testing/pyproject.toml deleted file mode 100644 index f1bda8df9..000000000 --- a/packages/smithy-testing/pyproject.toml +++ /dev/null @@ -1,53 +0,0 @@ -[project] -name = "smithy-testing" -dynamic = ["version"] -requires-python = ">=3.12" -authors = [ - {name = "Amazon Web Services"}, -] -description = "Core components for testing Smithy tooling in Python." -readme = "README.md" -license = {text = "Apache License 2.0"} -keywords = ["smithy", "sdk"] -classifiers = [ - "Development Status :: 2 - Pre-Alpha", - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "Natural Language :: English", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.14", - "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Software Development :: Libraries" -] -dependencies = [] - -[project.urls] -"Changelog" = "https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-testing/CHANGELOG.md" -"Code" = "https://github.com/smithy-lang/smithy-python/blob/develop/packages/smithy-testing/" -"Issue tracker" = "https://github.com/smithy-lang/smithy-python/issues" - -[dependency-groups] -typing = [ - "typing_extensions>=4.13.0", -] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.hatch.version] -path = "src/smithy_testing/__init__.py" - -[tool.hatch.build] -exclude = [ - "tests", -] - -[tool.ruff] -src = ["src"] diff --git a/packages/smithy-testing/src/smithy_testing/py.typed b/packages/smithy-testing/src/smithy_testing/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/smithy-testing/tests/__init__.py b/packages/smithy-testing/tests/__init__.py deleted file mode 100644 index 04f8b7b76..000000000 --- a/packages/smithy-testing/tests/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 diff --git a/packages/smithy-testing/tests/py.typed b/packages/smithy-testing/tests/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/smithy-testing/tests/unit/__init__.py b/packages/smithy-testing/tests/unit/__init__.py deleted file mode 100644 index 04f8b7b76..000000000 --- a/packages/smithy-testing/tests/unit/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 diff --git a/pyproject.toml b/pyproject.toml index 1078e8b27..d7a23d99e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,6 @@ smithy_json = { workspace = true } smithy_aws_core = { workspace = true } smithy_aws_event_stream = { workspace = true } aws_sdk_signers = {workspace = true } -smithy_testing = { workspace = true } [tool.pyright] typeCheckingMode = "strict" diff --git a/uv.lock b/uv.lock index dde32275d..3bf8fb831 100644 --- a/uv.lock +++ b/uv.lock @@ -11,7 +11,6 @@ members = [ "smithy-http", "smithy-json", "smithy-python", - "smithy-testing", ] [[package]] @@ -731,20 +730,6 @@ test = [ ] typing = [{ name = "pyright", specifier = ">=1.1.400" }] -[[package]] -name = "smithy-testing" -source = { editable = "packages/smithy-testing" } - -[package.dev-dependencies] -typing = [ - { name = "typing-extensions" }, -] - -[package.metadata] - -[package.metadata.requires-dev] -typing = [{ name = "typing-extensions", specifier = ">=4.13.0" }] - [[package]] name = "typing-extensions" version = "4.13.2"