Files
aurum/backend/tests
ZProger c3309b9d60 feat: click a coin row to view its trade history; edit transactions
Matches CoinMarketCap's flow: clicking anywhere on a coin's row in the
holdings table opens its transaction history (previously only a dedicated
icon button did). The table's own History icon is gone since the row now
does that job; the remaining "+"/delete icons get stopPropagation so they
don't also trigger the row click.

Adds the missing piece: transactions could be viewed and deleted but not
edited. New PATCH /crypto/transactions/{id} (partial update, never calls
CoinGecko, same oversell guard as creating a sell) backs a pencil button on
each history row that opens CryptoTransactionModal pre-filled — the same
dialog used for "+", now doing double duty as create/edit.

86/86 backend tests passing (4 new). Verified live against the real API:
create, edit quantity/note, 404 on unknown id, cleanup — real user data
untouched throughout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01855PiW5Wd8n4aRW4n9kByY
2026-08-30 05:06:20 +03:00
..

Backend tests

Real integration tests against a real Postgres database — a dedicated aurum_test database created fresh, migrated, and dropped again on every run. They never touch the real aurum database or its data: the app's lifespan startup (which seeds against the real DB) is never triggered, and every route's DB dependency is overridden to point at aurum_test instead.

Running

The stack must already be up (docker compose up -d). Test dependencies aren't baked into the production image, so install them once per container lifetime, then run pytest inside the running backend container — it's the only place with network access to Postgres:

docker compose exec backend pip install -r requirements-dev.txt
docker compose exec backend pytest -v

Re-run just pytest -v for subsequent runs; the pip install only needs repeating after a container restart/rebuild.

Adding a test

  • Use the client fixture (an httpx.AsyncClient wired to the app) to hit the API the same way the frontend does — prefer this over reaching into services/models directly, so tests keep verifying the actual contract.
  • account_id and categories fixtures give you the same default account/categories a real fresh install seeds.
  • Every table is truncated and reseeded before each test (see conftest.py::_clean_database), so tests don't need to worry about leftover state or guess at IDs from a previous test.