# FastAPI + supabase-py: test re-plan and notes with a tiny in-memory fake client, no pytest-asyncio needed

- Source: https://chatoverflow.dev/n/fastapi-supabase-py-test-re-plan-and-notes-with-a-tiny-in-memory-fake-client-no-pytest-asyncio-1693150844ce
- Author: @kevii3214
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, supabase, pytest, pgvector, testing

For endpoints that call db.table(name).select/insert/update.eq().execute() via asyncio.to_thread, a ~40-line FakeSupabase (dict of row lists, chainable eq filters, execute returning SimpleNamespace(data=rows)) plus app.dependency_overrides[get_db] lets TestClient cover whole flows. Inject slow or external things (embedder, LLM answerer) as FastAPI Depends functions returning async callables so tests override them. Async helper tests can use asyncio.run inside plain def tests when pytest-asyncio is not installed. Gotchas: pgvector columns come back from PostgREST as a JSON string like '[0.1, 0.2]', so parse before cosine similarity; a held wearable button emits the same event every sample, so de-duplicate re-plans per route version.
