Skip to content

Add integration tests for connecthealth#62

Open
Alan4506 wants to merge 1 commit into
awslabs:developfrom
Alan4506:connecthealth-test
Open

Add integration tests for connecthealth#62
Alan4506 wants to merge 1 commit into
awslabs:developfrom
Alan4506:connecthealth-test

Conversation

@Alan4506
Copy link
Copy Markdown
Contributor

Add integration tests for Connect Health

Description of Changes

This PR adds the integration tests for Connect Health under tests/integration/:

  • conftest.py: session-scoped fixture that creates a Domain, an ACTIVE Subscription, and an S3 bucket, yields (domain_id, subscription_id, output_s3_uri) to the tests, and tears everything down afterwards. The Domain and Subscription waiters are built with botocore.waiter.create_waiter_with_client against an inline WaiterModel, since Connect Health does not yet ship built-in waiters.
  • test_non_streaming.py: covers ListDomains / GetDomain and ListSubscriptions / GetSubscription, asserting on the fields the service is expected to return.
  • test_bidirectional_streaming.py: exercises StartMedicalScribeListeningSession end-to-end. It sends a MedicalScribeConfigurationEvent, streams test.wav audio at realtime pace, asserts on transcript segments received on the output stream, then calls GetMedicalScribeListeningSession to verify the session reaches COMPLETED state with the expected configuration round-tripped.
  • assets/test.wav: short 16 kHz / 16-bit / mono PCM medical encounter recording used as the streaming input.

Existing limitation

When we tried to build the fixture with the new SDK, we hit the following: when the service omits the @required lastUpdatedAt field from a CreateSubscriptionOutput response, the generated dataclass constructor raises TypeError, which the SDK pipeline then surfaces as smithy_core.exceptions.SmithyError: CreateSubscriptionOutput.__init__() missing 1 required keyword-only argument: 'last_updated_at'. The Smithy spec defines client error correction for exactly this scenario, but smithy-python has not yet implemented it (although we have tracked this in our backlog). As a result, we cannot use the new SDK to perform CreateSubscription in fixture setup today; the boto3 client (which tolerates the missing field) is used instead.

If we still decide to use the new SDK for resource setup rather than boto3, a workaround would look like the following:

async def _create_subscription(client: ConnectHealthClient, domain_id: str) -> str:
    """Create a Subscription on ``domain_id``. We have to use 
    ListSubscriptions to recover the new ID.
    """
    try:
        response = await client.create_subscription(
            input=CreateSubscriptionInput(domain_id=domain_id)
        )
        return response.subscription_id
    except SmithyError as e:
        if "last_updated_at" not in str(e):
            raise
        listing = await client.list_subscriptions(
            input=ListSubscriptionsInput(domain_id=domain_id)
        )
        for sub in listing.subscriptions or []:
            return sub.subscription_id
        raise RuntimeError(
            "create_subscription failed and no Subscription was found on Domain "
            f"{domain_id}"
        ) from e

We will revisit the conftest once smithy-python implements client error correction.

Testing

The integration tests create real AWS resources (Domain, Subscription, S3 bucket) under the calling AWS identity, run a live streaming session against the Connect Health service, then delete those resources. The calling identity therefore needs Admin (or equivalent) permissions on ConnectHealth and S3.

  1. Assume an Admin role and export the resulting credentials so the new SDK (which uses EnvironmentCredentialsResolver) can pick them up:

    export AWS_ACCESS_KEY_ID=...
    export AWS_SECRET_ACCESS_KEY=...
    export AWS_SESSION_TOKEN=...
  2. From clients/aws-sdk-connecthealth/, install the client and test dependencies:

    uv pip install -e . --group test
  3. Run the tests

    python -m pytest tests/

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

@Alan4506 Alan4506 requested a review from a team as a code owner May 22, 2026 16:58
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.

1 participant