Skip to main content

Python testing SDK for local-web-services — in-process pytest fixtures and boto3 helpers

Project description

local-web-services-testing

Python testing SDK for local-web-services — in-process pytest fixtures and boto3 helpers for testing AWS applications without needing a running ldk dev.

Installation

pip install local-web-services-python-sdk
# or
uv add local-web-services-python-sdk

Quick start

from lws_testing import LwsSession

# Auto-discover resources from a CDK project
with LwsSession.from_cdk("../my-cdk-project") as session:
    dynamo = session.client("dynamodb")
    dynamo.put_item(TableName="Orders", Item={"id": {"S": "1"}})

# Auto-discover resources from a Terraform project
with LwsSession.from_hcl("../my-terraform-project") as session:
    s3 = session.client("s3")
    s3.put_object(Bucket="my-bucket", Key="test.txt", Body=b"hello")

# Explicit resource declaration
with LwsSession(
    tables=[{"name": "Orders", "partition_key": "id"}],
    queues=["OrderQueue"],
    buckets=["ReceiptsBucket"],
) as session:
    table = session.dynamodb("Orders")
    table.put({"id": {"S": "1"}, "status": {"S": "pending"}})
    items = table.scan()
    assert len(items) == 1

pytest integration

The package registers pytest fixtures automatically via the pytest11 entry point. Add a session fixture to your conftest.py:

# conftest.py
import pytest

@pytest.fixture(scope="session")
def lws_session_spec():
    return {
        "tables": [{"name": "Orders", "partition_key": "id"}],
        "queues": ["OrderQueue"],
    }

Then use the lws_session fixture in your tests:

def test_create_order(lws_session):
    client = lws_session.client("dynamodb")
    client.put_item(TableName="Orders", Item={"id": {"S": "42"}})

    table = lws_session.dynamodb("Orders")
    table.assert_item_exists({"id": {"S": "42"}})

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

local_web_services_python_sdk-0.1.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

local_web_services_python_sdk-0.1.1-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file local_web_services_python_sdk-0.1.1.tar.gz.

File metadata

File hashes

Hashes for local_web_services_python_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1f0b29215a13ff1ae357ff01844c3107c4e2d4b4db76ec47f33aeb6122beba26
MD5 7fea6f5d575540e3ea6e3d36acb7df1c
BLAKE2b-256 b15aacf7b4be7fa2efd1f98b2365f6a1aa226b94defb807e9487ca7e38368699

See more details on using hashes here.

Provenance

The following attestation bundles were made for local_web_services_python_sdk-0.1.1.tar.gz:

Publisher: publish.yml on local-web-services/local-web-services-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file local_web_services_python_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for local_web_services_python_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1976aa6850cac4e0b43d7295a8a3e204db28eaafeac22947b5007dcdce639bc0
MD5 46b22917998c3cac58c0c671a709a67d
BLAKE2b-256 2dd92ec00591950dabc1e49b8d34fe4d7c5597a799c487c81c1cc219c2217ff2

See more details on using hashes here.

Provenance

The following attestation bundles were made for local_web_services_python_sdk-0.1.1-py3-none-any.whl:

Publisher: publish.yml on local-web-services/local-web-services-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page