Model/backend/export
Khalim Conn-Kowlessar b97d06882f feat(modelling): drop the plan_recommendations m2m
Stop writing the m2m (remove create_plan_recommendations + its call, the bulk
link insert and the now-dead plan_ids_by_index, and the plan_recommendations
delete in delete_property_batch) and remove the PlanRecommendationRow model +
its shim alias and the test_export fixture inserts. Measures now link to their
Plan solely via recommendation.plan_id (writers set it, readers join on it).

The live drop of the plan_recommendations table is the FE-owned Drizzle
migration documented in docs/migrations/recommendation-plan-id.md, sequenced
after the read-cut + backfill.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 21:13:00 +00:00
..
property_scenarios feat(modelling): cut plan→recommendation readers onto plan_id 2026-06-03 21:09:43 +00:00
tests feat(modelling): drop the plan_recommendations m2m 2026-06-03 21:13:00 +00:00
README.md added postgres to docker & added to readme 2026-02-27 18:58:59 +00:00

🧪 Running Tests in PyCharm (macOS + pytest-postgresql)

Our test suite uses pytest and pytest-postgresql, which automatically spins up a temporary PostgreSQL instance.

On Linux (including GitHub Actions), PostgreSQL binaries are installed in standard system locations.
On macOS (Homebrew), they are not --- so PyCharm needs a small configuration tweak to locate pg_ctl.

This guide explains how to run and debug tests locally in PyCharm without modifying test code.


Prerequisites

Devcontainer

Postgres install is included in the devcontainer, so no additional setup is needed.

Running

make test

Will instigate the test suite, which will automatically start a temporary PostgreSQL instance.

Local MacOS

  1. Install PostgreSQL via Homebrew:
brew install postgresql
  1. Confirm pg_ctl exists:
which pg_ctl

Typical output:

/opt/homebrew/bin/pg_ctl

🚀 Running Tests in PyCharm

Step 1 --- Create a PyCharm pytest Run Configuration

  1. Open the test file.
  2. Click the green ▶ next to the test.
  3. Choose "Edit Run Configuration..."

You should see something like:

  • Target: backend/export/tests/test_export.py
  • Working directory: Project root (e.g.Model/)

Step 2 --- Add Required Override (macOS Only)

In the Run Configuration:

➜ "Additional Arguments"

Add:

--override-ini=postgresql_exec=/opt/homebrew/bin/pg_ctl

This tells pytest-postgresql where pg_ctl lives on macOS.

Without this, PyCharm may fail with:

ExecutableMissingException: Could not found pg_config executable

Step 3 --- Run or Debug

You can now:

  • Click ▶ Run\
  • Click 🐞 Debug\
  • Set breakpoints normally

The temporary PostgreSQL instance will start automatically.


🔍 Why This Is Needed

pytest-postgresql defaults to a Linux-style path:

/usr/lib/postgresql/<version>/bin/pg_ctl

That path exists on Ubuntu (CI), but not on macOS.

On macOS, Homebrew installs PostgreSQL in:

/opt/homebrew/bin/

The --override-ini flag safely overrides the executable path locally, without modifying:

  • test files\
  • conftest.py\
  • pytest.ini\
  • CI configuration

This ensures:

  • Tests still work in GitHub Actions\
  • Tests still work for Linux users\
  • macOS developers can debug in PyCharm\
  • No repository-specific hacks are required

🛠 Optional: Using a Local .env File

If you prefer not to hardcode the override in the run configuration:

  1. Create a local file:
<!-- -->
.env.local
  1. Add:
<!-- -->
PYTEST_ADDOPTS=--override-ini=postgresql_exec=/opt/homebrew/bin/pg_ctl
  1. In PyCharm:
    • Open the Run Configuration
    • Add .env.local under "Paths to .env files"

🧪 Running Tests via Terminal (Recommended for CI Parity)

For normal execution outside PyCharm:

make test

These already work without additional configuration.


🧠 Summary

Environment Works Without Override? Needs --override-ini?


GitHub Actions (Linux) Yes No Linux local Yes No macOS terminal (tox) Yes No macOS PyCharm debugger No Yes