Asyncpg Live Vs Mock Shape

Use when writing pytest mocks for asyncpg-backed endpoints where the column type causes mock-vs-live divergence (SUM/COUNT/AVG → Decimal; JSONB → str; UUID → UUID-object; INET → str). asyncpg returns raw PG-types that don't match naive intuition — mocks with the "natural" dict/int/float pass shape-tests but the real DB-call fails live. Trigger on phrases like "asyncpg mock test", "asyncpg JSONB mock", "asyncpg returns string for JSONB", "TypeError Decimal float", "AttributeError str object no attribute keys", "mock-and-live diverge for asyncpg". Do NOT load for psycopg-2-based tests (different driver, auto-coerces JSONB), for SQLAlchemy ORM tests (the ORM coerces types), or for asyncpg connections with `set_type_codec('jsonb', ...)` registered (the codec handles conversion).

Ed3Design 07b0af6 14.1 KB Updated

File contents

Ed3Design/ed3design-skill-bundles/tree/main/async-forensik/skills/asyncpg-live-vs-mock-shape commit 07b0af6b33

Frequently asked questions

npx skillmds@latest add ed3design/asyncpg-live-vs-mock-shape