Metadata-Version: 2.4
Name: local-web-services-python-sdk
Version: 0.1.1
Summary: Python testing SDK for local-web-services — in-process pytest fixtures and boto3 helpers
Project-URL: Homepage, https://local-web-services.github.io/www
Project-URL: Repository, https://github.com/local-web-services/local-web-services-sdk-python
Project-URL: Issues, https://github.com/local-web-services/local-web-services-sdk-python/issues
License-Expression: MIT
Keywords: aws,boto3,dynamodb,local,mocking,pytest,s3,sqs,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.11
Requires-Dist: botocore>=1.34.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: local-web-services>=0.17.2
Requires-Dist: pyyaml>=6.0
Provides-Extra: pytest
Requires-Dist: pytest>=8.0.0; extra == 'pytest'
Description-Content-Type: text/markdown

# local-web-services-testing

Python testing SDK for [local-web-services](https://github.com/local-web-services/local-web-services) — in-process pytest fixtures and boto3 helpers for testing AWS applications without needing a running `ldk dev`.

## Installation

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

## Quick start

```python
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`:

```python
# 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:

```python
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
