Skip to content

Add HTTP recording to smithy-test - #986

Merged
kuhe merged 1 commit into
developfrom
kuhe/feat/http-record
Nov 24, 2026
Merged

kuhe merged 1 commit into
developfrom
kuhe/feat/http-record

Conversation

@kuhe

@kuhe kuhe commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds a smithy-test API called instrument for recording and playing back live-service integration tests as functional http mock tests.

For an example, see aws/aws-sdk-python#154.

Data streams are supported (S3), but event streams are not supported in this PR.

Usage

We got controller = mock(client) in #917, now we get instrument(client).

from aws_sdk_s3.client import S3Client
from smithy_test import instrument


def test_something() -> None:
    client = S3Client()
    instrument(client)
    
    buckets = client.list_buckets()
    assert ...

By instrumenting your client, it can then run in two modes:

  1. SMITHY_PYTHON_TEST_MODE=record - this modes writes the operation responses as Python code into the recordings path. You can review and commit these.
  2. SMITHY_PYTHON_TEST_MODE=playback - (default) this uses the recordings to mock the http responses, allowing the same test to execute offline.

Both modes honor assertions made in the written tests.

Write your test once, record it to get an honest server mock response, and then have a durable offline test.

@kuhe
kuhe force-pushed the kuhe/feat/http-record branch 9 times, most recently from f378b00 to db011ba Compare November 24, 2026 18:28
@kuhe
kuhe force-pushed the kuhe/feat/http-record branch 2 times, most recently from cd43b33 to 419cd8a Compare November 24, 2026 18:55
@kuhe
kuhe force-pushed the kuhe/feat/http-record branch from 419cd8a to 2e24ed5 Compare November 24, 2026 19:19
@kuhe
kuhe marked this pull request as ready for review November 24, 2026 20:27
@kuhe
kuhe requested a review from a team as a code owner November 24, 2026 20:27
@kuhe
kuhe merged commit 756f8aa into develop Nov 24, 2026
26 checks passed
@kuhe
kuhe deleted the kuhe/feat/http-record branch November 24, 2026 21:00
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.

3 participants