local-web-services-python-sdk 0.1.6__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/PKG-INFO +2 -2
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/pyproject.toml +5 -2
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/requirements.txt +0 -2
- local_web_services_python_sdk-0.2.0/src/lws_testing/_builders/__init__.py +1 -0
- local_web_services_python_sdk-0.1.6/src/lws_testing/_builders/mock.py → local_web_services_python_sdk-0.2.0/src/lws_testing/_builders/fake.py +17 -17
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_transport/inprocess.py +17 -17
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/session.py +6 -6
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/unit/test_session_imports.py +1 -1
- local_web_services_python_sdk-0.1.6/src/lws_testing/_builders/__init__.py +0 -1
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/.github/workflows/ci.yml +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/.github/workflows/publish.yml +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/.gitignore +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/BUILD +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/Makefile +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/README.md +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/__init__.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_builders/chaos.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_builders/iam.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_discovery/__init__.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_discovery/cdk.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_discovery/hcl.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_logs.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_resources/__init__.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_resources/dynamodb.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_resources/s3.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_resources/sqs.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_transport/__init__.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/fixtures.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/BUILD +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/__init__.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/pytest_runner.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/unit/__init__.py +0 -0
- {local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/unit/test_session_lifecycle.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: local-web-services-python-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Python testing SDK for local-web-services — in-process pytest fixtures and boto3 helpers
|
|
5
5
|
Project-URL: Homepage, https://local-web-services.github.io
|
|
6
6
|
Project-URL: Repository, https://github.com/local-web-services/local-web-services-sdk-python
|
|
7
7
|
Project-URL: Issues, https://github.com/local-web-services/local-web-services-sdk-python/issues
|
|
8
8
|
License-Expression: MIT
|
|
9
|
-
Keywords: aws,boto3,dynamodb,local,
|
|
9
|
+
Keywords: aws,boto3,dynamodb,faking,local,pytest,s3,sqs,testing
|
|
10
10
|
Classifier: Development Status :: 3 - Alpha
|
|
11
11
|
Classifier: Framework :: Pytest
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "local-web-services-python-sdk"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "Python testing SDK for local-web-services — in-process pytest fixtures and boto3 helpers"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
requires-python = ">=3.11"
|
|
8
|
-
keywords = ["aws", "testing", "pytest", "boto3", "local", "dynamodb", "sqs", "s3", "
|
|
8
|
+
keywords = ["aws", "testing", "pytest", "boto3", "local", "dynamodb", "sqs", "s3", "faking"]
|
|
9
9
|
classifiers = [
|
|
10
10
|
"Development Status :: 3 - Alpha",
|
|
11
11
|
"Intended Audience :: Developers",
|
|
@@ -81,3 +81,6 @@ disable = [
|
|
|
81
81
|
"R0903", "R0902", "R0913", "R0917", "R0904", "R0911", "R0914", "C0103",
|
|
82
82
|
"W0603", "W0621", "C0415", "C0116", "W0212",
|
|
83
83
|
]
|
|
84
|
+
|
|
85
|
+
[tool.uv.sources]
|
|
86
|
+
local-web-services = { path = "../../../core", editable = true }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Fluent builders for fake, chaos, and IAM configuration."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Fluent builder for configuring AWS operation
|
|
1
|
+
"""Fluent builder for configuring AWS operation fakes."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -7,12 +7,12 @@ from typing import Any
|
|
|
7
7
|
import httpx
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class
|
|
11
|
-
"""Fluent builder for AWS service
|
|
10
|
+
class FakeBuilder:
|
|
11
|
+
"""Fluent builder for AWS service fake responses.
|
|
12
12
|
|
|
13
13
|
Usage::
|
|
14
14
|
|
|
15
|
-
session.
|
|
15
|
+
session.fake("dynamodb").operation("PutItem").respond(
|
|
16
16
|
status=500,
|
|
17
17
|
body={"__type": "ProvisionedThroughputExceededException"},
|
|
18
18
|
)
|
|
@@ -23,11 +23,11 @@ class MockBuilder:
|
|
|
23
23
|
self._mgmt_port = mgmt_port
|
|
24
24
|
self._rules: list[dict[str, Any]] = []
|
|
25
25
|
|
|
26
|
-
def operation(self, operation_name: str) ->
|
|
27
|
-
"""Start building a
|
|
28
|
-
return
|
|
26
|
+
def operation(self, operation_name: str) -> _FakeRuleBuilder:
|
|
27
|
+
"""Start building a fake rule for *operation_name*."""
|
|
28
|
+
return _FakeRuleBuilder(self, operation_name)
|
|
29
29
|
|
|
30
|
-
def _add_rule(self, rule: dict[str, Any]) ->
|
|
30
|
+
def _add_rule(self, rule: dict[str, Any]) -> FakeBuilder:
|
|
31
31
|
self._rules.append(rule)
|
|
32
32
|
self._apply()
|
|
33
33
|
return self
|
|
@@ -35,30 +35,30 @@ class MockBuilder:
|
|
|
35
35
|
def _apply(self) -> None:
|
|
36
36
|
"""Push the current rules to the management API."""
|
|
37
37
|
httpx.post(
|
|
38
|
-
f"http://127.0.0.1:{self._mgmt_port}/_ldk/aws-
|
|
38
|
+
f"http://127.0.0.1:{self._mgmt_port}/_ldk/aws-fake",
|
|
39
39
|
json={self._service: {"enabled": True, "rules": self._rules}},
|
|
40
40
|
timeout=5.0,
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
def clear(self) -> None:
|
|
44
|
-
"""Remove all
|
|
44
|
+
"""Remove all fake rules for this service."""
|
|
45
45
|
self._rules = []
|
|
46
46
|
httpx.post(
|
|
47
|
-
f"http://127.0.0.1:{self._mgmt_port}/_ldk/aws-
|
|
47
|
+
f"http://127.0.0.1:{self._mgmt_port}/_ldk/aws-fake",
|
|
48
48
|
json={self._service: {"enabled": False, "rules": []}},
|
|
49
49
|
timeout=5.0,
|
|
50
50
|
)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
class
|
|
54
|
-
"""Intermediate builder — configure a single
|
|
53
|
+
class _FakeRuleBuilder:
|
|
54
|
+
"""Intermediate builder — configure a single fake rule."""
|
|
55
55
|
|
|
56
|
-
def __init__(self, parent:
|
|
56
|
+
def __init__(self, parent: FakeBuilder, operation: str) -> None:
|
|
57
57
|
self._parent = parent
|
|
58
58
|
self._operation = operation
|
|
59
59
|
self._match_headers: dict[str, str] = {}
|
|
60
60
|
|
|
61
|
-
def with_header(self, name: str, value: str) ->
|
|
61
|
+
def with_header(self, name: str, value: str) -> _FakeRuleBuilder:
|
|
62
62
|
"""Add an additional header match constraint."""
|
|
63
63
|
self._match_headers[name] = value
|
|
64
64
|
return self
|
|
@@ -69,7 +69,7 @@ class _MockRuleBuilder:
|
|
|
69
69
|
body: str | dict[str, Any] = "",
|
|
70
70
|
content_type: str = "application/json",
|
|
71
71
|
delay_ms: int = 0,
|
|
72
|
-
) ->
|
|
72
|
+
) -> FakeBuilder:
|
|
73
73
|
"""Set the response and register the rule.
|
|
74
74
|
|
|
75
75
|
Args:
|
|
@@ -99,7 +99,7 @@ class _MockRuleBuilder:
|
|
|
99
99
|
|
|
100
100
|
return self._parent._add_rule(rule)
|
|
101
101
|
|
|
102
|
-
def error(self, error_type: str, message: str = "", status: int = 400) ->
|
|
102
|
+
def error(self, error_type: str, message: str = "", status: int = 400) -> FakeBuilder:
|
|
103
103
|
"""Respond with a structured AWS error."""
|
|
104
104
|
import json
|
|
105
105
|
|
|
@@ -108,9 +108,9 @@ class _StubOrchestrator:
|
|
|
108
108
|
def _create_management_app(
|
|
109
109
|
providers: dict[str, Any],
|
|
110
110
|
chaos_configs: dict[str, Any],
|
|
111
|
-
|
|
111
|
+
fake_configs: dict[str, Any],
|
|
112
112
|
) -> Any:
|
|
113
|
-
"""Build a FastAPI management app with reset,
|
|
113
|
+
"""Build a FastAPI management app with reset, fake, and chaos endpoints."""
|
|
114
114
|
from fastapi import FastAPI
|
|
115
115
|
from fastapi.responses import JSONResponse
|
|
116
116
|
from lws.api.management import _handle_reset, create_management_router
|
|
@@ -122,7 +122,7 @@ def _create_management_app(
|
|
|
122
122
|
orchestrator=orchestrator,
|
|
123
123
|
providers=providers,
|
|
124
124
|
chaos_configs=chaos_configs,
|
|
125
|
-
|
|
125
|
+
aws_fake_configs=fake_configs,
|
|
126
126
|
)
|
|
127
127
|
app.include_router(router)
|
|
128
128
|
|
|
@@ -182,7 +182,7 @@ def _build_service_apps(
|
|
|
182
182
|
providers: dict[str, Any],
|
|
183
183
|
ports: dict[str, int],
|
|
184
184
|
chaos_configs: dict[str, Any],
|
|
185
|
-
|
|
185
|
+
fake_configs: dict[str, Any],
|
|
186
186
|
cfg: dict[str, list[Any]],
|
|
187
187
|
) -> list[tuple[str, Any]]:
|
|
188
188
|
"""Build FastAPI apps for all services; return as (service_name, app) pairs."""
|
|
@@ -200,7 +200,7 @@ def _build_service_apps(
|
|
|
200
200
|
create_dynamodb_app(
|
|
201
201
|
providers["dynamodb"],
|
|
202
202
|
chaos=chaos_configs["dynamodb"],
|
|
203
|
-
|
|
203
|
+
aws_fake=fake_configs["dynamodb"],
|
|
204
204
|
),
|
|
205
205
|
),
|
|
206
206
|
(
|
|
@@ -209,7 +209,7 @@ def _build_service_apps(
|
|
|
209
209
|
providers["sqs"],
|
|
210
210
|
port=ports["sqs"],
|
|
211
211
|
chaos=chaos_configs["sqs"],
|
|
212
|
-
|
|
212
|
+
aws_fake=fake_configs["sqs"],
|
|
213
213
|
),
|
|
214
214
|
),
|
|
215
215
|
(
|
|
@@ -217,7 +217,7 @@ def _build_service_apps(
|
|
|
217
217
|
create_s3_app(
|
|
218
218
|
providers["s3"],
|
|
219
219
|
chaos=chaos_configs["s3"],
|
|
220
|
-
|
|
220
|
+
aws_fake=fake_configs["s3"],
|
|
221
221
|
),
|
|
222
222
|
),
|
|
223
223
|
(
|
|
@@ -225,7 +225,7 @@ def _build_service_apps(
|
|
|
225
225
|
create_sns_app(
|
|
226
226
|
providers["sns"],
|
|
227
227
|
chaos=chaos_configs["sns"],
|
|
228
|
-
|
|
228
|
+
aws_fake=fake_configs["sns"],
|
|
229
229
|
),
|
|
230
230
|
),
|
|
231
231
|
(
|
|
@@ -233,7 +233,7 @@ def _build_service_apps(
|
|
|
233
233
|
create_stepfunctions_app(
|
|
234
234
|
providers["stepfunctions"],
|
|
235
235
|
chaos=chaos_configs["stepfunctions"],
|
|
236
|
-
|
|
236
|
+
aws_fake=fake_configs["stepfunctions"],
|
|
237
237
|
),
|
|
238
238
|
),
|
|
239
239
|
(
|
|
@@ -241,7 +241,7 @@ def _build_service_apps(
|
|
|
241
241
|
create_ssm_app(
|
|
242
242
|
initial_parameters=cfg["parameters"] or None,
|
|
243
243
|
chaos=chaos_configs["ssm"],
|
|
244
|
-
|
|
244
|
+
aws_fake=fake_configs["ssm"],
|
|
245
245
|
),
|
|
246
246
|
),
|
|
247
247
|
(
|
|
@@ -249,7 +249,7 @@ def _build_service_apps(
|
|
|
249
249
|
create_secretsmanager_app(
|
|
250
250
|
initial_secrets=cfg["secrets"] or None,
|
|
251
251
|
chaos=chaos_configs["secretsmanager"],
|
|
252
|
-
|
|
252
|
+
aws_fake=fake_configs["secretsmanager"],
|
|
253
253
|
),
|
|
254
254
|
),
|
|
255
255
|
]
|
|
@@ -268,7 +268,7 @@ async def _start_all_servers(
|
|
|
268
268
|
mgmt_port: int,
|
|
269
269
|
) -> list[Any]:
|
|
270
270
|
"""Start uvicorn servers for every service app plus the management app."""
|
|
271
|
-
from lws.providers.
|
|
271
|
+
from lws.providers.fakeserver.provider import start_uvicorn_server
|
|
272
272
|
|
|
273
273
|
servers: list[Any] = []
|
|
274
274
|
for svc, app in service_apps:
|
|
@@ -302,20 +302,20 @@ async def start_services(
|
|
|
302
302
|
passed directly to :func:`stop_services`.
|
|
303
303
|
"""
|
|
304
304
|
from lws.providers._shared.aws_chaos import AwsChaosConfig
|
|
305
|
-
from lws.providers._shared.
|
|
305
|
+
from lws.providers._shared.aws_operation_fake import AwsFakeConfig
|
|
306
306
|
|
|
307
307
|
log_handler = _setup_logging()
|
|
308
308
|
cfg = _convert_spec(spec)
|
|
309
309
|
providers = _create_providers(cfg, data_dir)
|
|
310
310
|
|
|
311
311
|
chaos_configs: dict[str, Any] = {s: AwsChaosConfig() for s in _SERVICE_NAMES}
|
|
312
|
-
|
|
312
|
+
fake_configs: dict[str, Any] = {s: AwsFakeConfig(service=s) for s in _SERVICE_NAMES}
|
|
313
313
|
ports: dict[str, int] = {s: _free_port() for s in _SERVICE_NAMES}
|
|
314
314
|
mgmt_port = _free_port()
|
|
315
315
|
|
|
316
|
-
service_apps = _build_service_apps(providers, ports, chaos_configs,
|
|
316
|
+
service_apps = _build_service_apps(providers, ports, chaos_configs, fake_configs, cfg)
|
|
317
317
|
await _start_providers(providers)
|
|
318
|
-
mgmt_app = _create_management_app(providers, chaos_configs,
|
|
318
|
+
mgmt_app = _create_management_app(providers, chaos_configs, fake_configs)
|
|
319
319
|
servers = await _start_all_servers(service_apps, ports, mgmt_app, mgmt_port)
|
|
320
320
|
|
|
321
321
|
return log_handler, ports, mgmt_port, servers
|
|
@@ -323,7 +323,7 @@ async def start_services(
|
|
|
323
323
|
|
|
324
324
|
async def stop_services(servers: list[Any]) -> None:
|
|
325
325
|
"""Gracefully stop all servers started by :func:`start_services`."""
|
|
326
|
-
from lws.providers.
|
|
326
|
+
from lws.providers.fakeserver.provider import stop_uvicorn_server
|
|
327
327
|
|
|
328
328
|
for server, task in reversed(servers):
|
|
329
329
|
await stop_uvicorn_server(server, task)
|
|
@@ -46,7 +46,7 @@ class LwsSession:
|
|
|
46
46
|
|
|
47
47
|
Starts all LWS service providers in background threads within the test
|
|
48
48
|
process, patches boto3 clients, and provides helpers for seeding state,
|
|
49
|
-
configuring
|
|
49
|
+
configuring fakes, capturing logs, and asserting side effects.
|
|
50
50
|
|
|
51
51
|
Use as a context manager::
|
|
52
52
|
|
|
@@ -341,13 +341,13 @@ class LwsSession:
|
|
|
341
341
|
"""
|
|
342
342
|
return f"http://127.0.0.1:{self._ports['sqs']}/000000000000/{queue_name}"
|
|
343
343
|
|
|
344
|
-
# ──
|
|
344
|
+
# ── Fake / chaos / IAM builders ───────────────────────────────────────────
|
|
345
345
|
|
|
346
|
-
def
|
|
347
|
-
"""Return a fluent
|
|
348
|
-
from lws_testing._builders.
|
|
346
|
+
def fake(self, service: str) -> Any:
|
|
347
|
+
"""Return a fluent fake builder for the given service."""
|
|
348
|
+
from lws_testing._builders.fake import FakeBuilder
|
|
349
349
|
|
|
350
|
-
return
|
|
350
|
+
return FakeBuilder(service, self._mgmt_port)
|
|
351
351
|
|
|
352
352
|
def chaos(self, service: str) -> Any:
|
|
353
353
|
"""Return a fluent chaos builder for the given service."""
|
|
@@ -43,7 +43,7 @@ def test_resource_helpers_importable():
|
|
|
43
43
|
def test_builders_importable():
|
|
44
44
|
from lws_testing._builders.chaos import ChaosBuilder # noqa: F401
|
|
45
45
|
from lws_testing._builders.iam import IamBuilder # noqa: F401
|
|
46
|
-
from lws_testing._builders.
|
|
46
|
+
from lws_testing._builders.fake import FakeBuilder # noqa: F401
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
def test_discovery_importable():
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Fluent builders for mock, chaos, and IAM configuration."""
|
{local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/.github/workflows/ci.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/src/lws_testing/_logs.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/__init__.py
RENAMED
|
File without changes
|
{local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/pytest_runner.py
RENAMED
|
File without changes
|
{local_web_services_python_sdk-0.1.6 → local_web_services_python_sdk-0.2.0}/tests/unit/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|