How to push test data to the database

This guide describes how to load test/fixture data into the database for local development or QA. For full options per script, see populate-fixtures and seed-testing-data.

Prerequisites

  • Database: Containerised (Podman) PostgreSQL 18+ running; DATABASE_URL set (e.g. from .env.dev).
  • Migrations: Applied. From project root:
    uv run python main.py migrate
    

All commands below are run from the project root and assume uv is used (e.g. uv run python scripts/...).

Quick reference

Goal Script(s) Details
Orgs + projects (example TKI) seed_example_projects.py populate-fixtures
Orgs + projects (deprecated example) seed_from_ods.py populate-fixtures
WPs, tasks, 120 persons, assignments seed_testing_data.py seed-testing-datarequires existing projects + a child org
Non-working days (example calendar) seed_example_non_working_days.py populate-fixtures
EU projects (acronyms, dates, PMs) seed_eu_projects_from_org_details.py populate-eu-projects-from-org-details
Export DB → JSON, then reload export_fixture_from_db.py + seed_example_projects.py --json ... populate-fixtures
Docs screenshots (fictional data) seed_docs_screenshots.py + capture_docs_screenshots.py key-features

Recommended flow: full test dataset

Use this order so that projects and orgs exist before adding persons and assignments.

1. Migrate

uv run python main.py migrate

2. Load projects and orgs (choose one)

Option A — Example (supported)
Download data first (e.g. from fixture repo), then seed:

uv run python scripts/seed_example_projects.py --top-org EXAMPLE

Option B — Example from ODS (deprecated)
Creates the “Example project” and orgs from docs/example.ods:

uv run python scripts/seed_from_ods.py

3. (Optional) Non-working days

If using example orgs, load HOME org calendar from scripts/data/example_non_working_days.json:

uv run python scripts/seed_example_non_working_days.py --org EXAMPLE

4. (Optional) EU project details

If you have EU org-details JSON (e.g. from eu_playwright):

uv run python scripts/eu_portal/seed_eu_projects_from_org_details.py
# Or with custom path: --json tmp/downloaded_data/eu_playwright/org_details_example_results.json

5. Comprehensive testing data (WPs, tasks, persons, assignments)

Requires at least one child org (e.g. EXAMPLE-IT) and projects where that org is POO or partner. Adds 120 persons, WPs, tasks, and allocations:

uv run python scripts/seed_testing_data.py --home-org EXAMPLE-IT

Use a child org short name from Settings → ORGS (not the root, e.g. not EXAMPLE). Optional: --person-count, --limit-projects, --dry-run, --seed — see seed-testing-data.

One-shot sequence (example + testing data)

uv run python main.py migrate
uv run python scripts/seed_example_projects.py --top-org EXAMPLE
uv run python scripts/seed_example_non_working_days.py --org EXAMPLE
uv run python scripts/seed_testing_data.py --home-org EXAMPLE-IT

Then start the app: uv run python main.py run and open http://127.0.0.1:5000.

Idempotency and safety

  • Example seed: Idempotent; skips existing orgs (by short_name) and projects (by name).
  • Testing data seed: Idempotent; only adds data (persons, WPs, tasks, assignments, WBS); does not delete. Safe to re-run.
  • Non-working days: Idempotent; skips dates already present per org.

Automated tests

For pytest, use the db_with_example fixture; it runs migrations and loads the example project. You do not need to run seed scripts manually for tests.