s3dol.testing

s3dol.testing — a shipped in-memory fake and the exported conformance suite (ADR-0008). Downstream users can test services that take a store as a dependency with no network, no docker, no moto:

from s3dol.testing import mock_s3

def test_my_service():
    assert MediaService(mock_s3()).url('a')

The fake is not a re-implementation: FakeBucketStore is the real BucketStore with only the backend protocol (the _op_* seam of ADR-0002) swapped for a dict — so the prefix arithmetic, key validity, error taxonomy (the fake raises synthesized botocore ClientErrors through the same translation seam), guards and Mapping semantics are structurally identical, and drift fails the same conformance suite that gates the real store.

The suite is parameterized by capability flags: mock_s3() runs the structural presign assertion (2a) but not the fetch-it assertion (2b — there is no HTTP server), so the honest claim is “the same suite, parameterized by an ``endpoint_is_fetchable`` capability” (ADR-0008).

Functions

mock_s3([bucket, prefix, data, ...])

An in-process fake BucketStore: no network, no docker, no moto.

run_conformance(make_store, *[, ...])

Assert the s3dol store laws against a fresh store from make_store.

Classes

FakeBucketHandles(*args[, backing])

FakeBucketInfo(*args[, backing])

FakeBucketListedInfo(*args[, backing])

FakeBucketStore(*args[, backing])

The real BucketStore over a dict backend.

FakeBucketUrls(*args[, backing])

FakeObjectHandle(bucket, key, *, backing[, anon])

The fake's per-object escape hatch (mirrors ObjectHandle).

class s3dol.testing.FakeBucketHandles(*args, backing=None, **kwargs)[source]

Bases: _FakeOps, BucketHandles

class s3dol.testing.FakeBucketInfo(*args, backing=None, **kwargs)[source]

Bases: _FakeOps, BucketInfo

class s3dol.testing.FakeBucketListedInfo(*args, backing=None, **kwargs)[source]

Bases: _FakeOps, BucketListedInfo

class s3dol.testing.FakeBucketStore(*args, backing=None, **kwargs)[source]

Bases: _FakeOps, BucketStore

The real BucketStore over a dict backend.

class s3dol.testing.FakeBucketUrls(*args, backing=None, **kwargs)[source]

Bases: _FakeOps, BucketUrls

class s3dol.testing.FakeObjectHandle(bucket, key, *, backing, anon=False)[source]

Bases: object

The fake’s per-object escape hatch (mirrors ObjectHandle).

s3dol.testing.mock_s3(bucket='mock-bucket', *, prefix='', data=None, bucket_exists=True, anon=False)[source]

An in-process fake BucketStore: no network, no docker, no moto.

data seeds the bucket with absolute (wire) keys -> bytes.

>>> s = mock_s3(data={'logs/a.txt': b'hi', 'other/z': b'no'}, prefix='logs')
>>> list(s), s['a.txt']
(['a.txt'], b'hi')
>>> s['b'] = b'new'; sorted(s)
['a.txt', 'b']
Return type:

FakeBucketStore

s3dol.testing.run_conformance(make_store, *, endpoint_is_fetchable=False, normalize=<function <lambda>>, check_pickle=True, check_urls=True, secret=None)[source]

Assert the s3dol store laws against a fresh store from make_store.

make_store must return an EMPTY, writable store (each call may return a new one over the same empty backend). normalize is the per-layer canonical form of ADR-0005 N3 (identity for Layer B; json.loads ∘ json.dumps for a json recipe, …). secret, when given, is asserted absent from every repr this suite touches.

Sibling packages and user code are welcome to run this against their own stores — that is why it ships in the package rather than in tests/.

Return type:

None