Testing#

The project uses Django’s built-in test runner. Tests live alongside each app at app/richy/<app>/tests.py.

Run the full test suite#

$ docker exec -it richy ./manage.py test

Run a single app’s tests#

$ docker exec -it richy ./manage.py test richy.transactions

Run a single test case#

$ docker exec -it richy ./manage.py test \
      richy.transactions.tests.TransactionsTestCase.test_get_pile_stats

Useful flags#

  • --keepdb – reuse the test database between runs (much faster for iterating).

  • --failfast – stop on the first failure.

  • -v 2 – verbose output.

Example:

$ docker exec -it richy ./manage.py test --keepdb --failfast richy.shares

Time-sensitive tests#

The dev requirements include freezegun so date-dependent code paths (price history, dividend calculations, “today” comparisons) can be tested deterministically.

Test fixtures and data#

Each app’s fixtures/ directory contains seed data used by tests that need pre-populated rows (e.g., exchanges, the site tree, celery beat schedule). The transactions app additionally ships a test_data/ directory with realistic fixtures for performance and dividend calculations.