Skip to content

Conversation

@alexgromero
Copy link
Contributor

Issue #, if available:

Description of changes:

  • Adds modules to support functional testing of smithy-python clients.
  • Adds a MockHTTPClient to test generated clients without hitting live endpoints.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alexgromero alexgromero requested a review from a team as a code owner October 24, 2025 19:19
@alexgromero alexgromero changed the base branch from develop to functional-testing-framework October 24, 2025 19:22
Copy link
Contributor

@arandito arandito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alessandra! This looks great. Just left some minor comments about simplification and other nits.

client_config: HTTPClientConfiguration | None = None,
) -> None:
"""
:param client_config: Configuration that applies to all requests made with this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I think we'll be using Google style docstrings moving forward (see #564). I think for now that would cause the CI to fail so this is more of a heads up.

def add_response(
self,
status: int = 200,
headers: list[tuple[str, str]] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 49 we set fields to headers if it exists or to an empty list if it doesn't exist. Can we simplify this by defaulting headers to an empty list instead of making it an optional parameter with a default of None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I would prefer to keep the current pattern to stay consistent with the existing ResponseTestHTTPClient implementation in the generated protocol tests (see example here). This also avoids the mutable default argument issue in Python.

self._response_queue: deque[HTTPResponse] = deque()
self._captured_requests: list[HTTPRequest] = []

def add_response(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential idea for a helper function: it's pretty common in tests that we add multiple responses and test subsequent calls. It may be nice to have a helper function that sets a default response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted offline and will look into this, but we'll consider adding these convenience methods as we see need for this use case.

@alexgromero alexgromero force-pushed the add-testing-utilities-to-smithy-http branch from 0557a66 to 8467d11 Compare November 18, 2025 16:16
nateprewitt
nateprewitt previously approved these changes Nov 18, 2025
Copy link
Contributor

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: Thanks @alexgromero!

@alexgromero alexgromero changed the base branch from functional-testing-framework to develop November 18, 2025 20:11
@alexgromero alexgromero dismissed nateprewitt’s stale review November 18, 2025 20:11

The base branch was changed.

@alexgromero alexgromero merged commit d4ede90 into smithy-lang:develop Nov 18, 2025
SamRemis pushed a commit to SamRemis/smithy-python that referenced this pull request Nov 18, 2025
@alexgromero alexgromero deleted the add-testing-utilities-to-smithy-http branch November 25, 2025 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants