Repository navigation
Testing Review
Written against d5aad1f44 on 19 Nov 2026.
In short
- The backend collects 12,900 tests, with about 1.6 lines of test for each line of production code. The JavaScript trees add about 3,000 test call sites.
- The strongest parts are the contract suites that run on real engines, the tests the suite keeps on its own rules, and the failure modes it tests (a killed solve, memory, data narrowing).
- Between 24 Oct and 19 Nov 2026, 15 of 27 scheduled nightlies failed, in three streaks. The nightly is the routine run for Windows, macOS, the newer Pythons and the memory job.
- Mutation testing reports partial results: 18 of 20 packages in the latest run, with 5,120 surviving mutants. No run has finished whole, and by design nothing gates on it.
- Pull-request and nightly testing publish no combined coverage figure and enforce no minimum.
Testing philosophy explains the principles. This page counts what exists and assesses it.
-
Backend test counts are from
uv run --no-sync pytest --collect-only -q -p no:cacheproviderinbackend/, grouped by path. It collected 12,900 tests and ran none. -
Backend file counts are tracked files (
git ls-files) namedtest_*.py. Helpers andconftest.pyfiles are not counted. -
JavaScript counts are call sites, not collected cases. They are matches of
\b(it|test)\s*\(in tracked*.test.ts(x)files (unit) and*.spec.tsfiles (journeys and desktop).it.eachtables and Playwright projects expand them at run time. -
Line counts are
wc -lover tracked files. Backend production lines include the generated models and parser. -
CI statistics are from
gh run listandgh run viewon 19 Nov 2026. Each gives its date range. - No test suite or coverage run was executed for this review.
| Suite | Location | Files | Collected tests | What it covers |
|---|---|---|---|---|
| Old acceptance |
backend/tests/features/, backend/tests/steps/
|
104 features, 94 step modules | 1,942 (from 1,251 scenarios) | The HTTP API and the library, in-process |
| Four-layer acceptance | backend/tests/acceptance/ |
8 features (a ninth, a protocol probe, is under support/probes/) |
117 (57 scenarios, plus tests of the DSL, drivers and support) | Snapshot weightings and weighted solves, on a real server |
| Contract | backend/tests/contract/ |
7 | 44 | Status codes, routes, problem slugs, one memory bound |
| App-level pytest | backend/tests/test_*.py |
119, plus the old suite's entry point test_features.py
|
2,196 | The library, durability, memory, workflows, notebooks, CI scripts |
| Library suites | backend/libs/*/tests/ |
262 | 8,601 | Each workspace member alone |
Of the 2,196 app-level tests, 497 are the compile checks of test_source_compiles.py and 102 are notebook cases, of which 39 are skipped by default.
| Package | Source lines | Collected tests | Test lines | Test to source |
|---|---|---|---|---|
tz_ps_datawarehouse |
27,721 | 5,021 | 37,065 | 1.34 |
tz_ps_workflow |
7,564 | 803 | 11,175 | 1.48 |
tz_ps_models |
8,068 | 663 | 6,399 | 0.79 |
tz_ps_expressions |
4,112 | 448 | 1,917 | 0.47 |
tz_ps_pypsa |
13,653 | 322 | 3,838 | 0.28 |
tz_ps_runner |
2,826 | 264 | 4,871 | 1.72 |
tz_ps_solver_pypsa |
2,548 | 235 | 4,533 | 1.78 |
tz_ps_calliope |
3,403 | 159 | 1,681 | 0.49 |
tz_ps_durable_runner |
1,619 | 115 | 3,363 | 2.08 |
tz_ps_http |
8,124 | 83 | 1,505 | 0.19 |
| Eleven smaller members | 7,661 | 488 | 8,011 | 1.05 |
tz_ps_conductor (backend/src/) |
10,442 | tested from backend/tests/
|
-
Totals: about 97,700 production lines and 158,100 test lines (84,400 in the libraries, 58,600 of Python and 15,100 of Gherkin in
backend/tests/). -
Generated code lowers two ratios:
tz_ps_pypsais mostly generated models, andtz_ps_expressionsincludes its generated parser. -
tz_ps_httpis tested mainly from outside: the acceptance suites exercise it, so its own ratio of 0.19 understates its cover.
| Item | Count |
|---|---|
calliope tests |
468 |
slow tests |
104 |
inspects_code tests |
64 |
memory tests |
58 |
mutation_kit tests |
42 |
pypsa_coverage notebooks (7 also pypsa_weightings) |
39 |
skip and skipif sites |
71 |
sleep( sites in test code, including child scripts |
72 |
backend/tests/postgresql_expected_failures.txt |
66 entries, all strict |
backend/tests/acceptance/http_expected_failures.txt |
0 entries |
backend/tests/function_verbs_allow_list.txt |
262 entries, with the count pinned in the test |
The 66 PostgreSQL expected failures have three reasons: the PostgreSQL warehouse keeps no run values yet (55), it refuses a network rename, #1134 (10), and it reuses version ids for a network created again, #1412 (1).
| Suite | Framework | Files | Call sites | Test lines to source lines |
|---|---|---|---|---|
frontend unit |
Vitest, Testing Library, MSW | 138 | 2,047 | 67,300 to 59,067 |
frontend journeys |
Playwright, a real backend for each worker | 12 specs, 28 visual baselines | 90 | 4,514 |
frontend-next unit |
Vitest, Testing Library, MSW, axe-core | 37 | 646 | 19,277 to 17,433 |
frontend-next journeys |
Playwright, one shared backend | 7 specs | 20 | 764 |
frontend-sdk |
Vitest | 8 | 14 | 430 to 2,336 hand-written |
desktop |
Playwright Test, projects node, app, update
|
14 specs | 239 | 7,086 to 5,324 |
| Accessibility | Lighthouse, light and dark | frontend/scripts/a11y-audit.ts |
every page a crawl finds |
-
Coverage on pull requests and the nightly.
[tool.coverage.run]inbackend/pyproject.tomlnames 21 source packages. There is nofail_underand no upload. CI passes--covon Linux, and each shard prints only its own part to its log. -
Coverage weekly.
mutation-tests.ymlruns the suite in four parts with test contexts, combines them and uploads the data as themutation-coverageartefact. Its summary holds no coverage percentage. -
Coverage in JavaScript.
frontendhas atest:coveragescript that no workflow runs.frontend-nexthas none. -
Mutation.
backend/mutation.tomllists 21 packages, every one buttz_ps_testing. The design (docs/specs/2026-10-27-mutation-testing-design.md) lists "a score that fails a run" as a non-goal. Thereportjob runs whenever the coverage job passed, so it publishes the packages that finished even when another failed.
Mutation results of the latest run (18 Nov 2026, manual dispatch, commit 2440c350c), from its mutation-results artefact:
| Count | |
|---|---|
| Packages reported | 18 of 20. tz_ps_datawarehouse was cancelled and tz_ps_expressions failed |
| Mutants killed | 16,157 |
| Mutants that survived | 5,120 |
Mutants no test reaches (no_tests) |
6,793, of which 2,708 are in tz_ps_http
|
| Mutants not yet run | 8,369, mostly tz_ps_conductor (5,850) and tz_ps_workflow (2,367) |
| Timeouts | 517, of which 457 are in tz_ps_workflow
|
| Packages with a complete kill matrix | 1 (tz_ps_app) |
Of the mutants that were tested and gave a verdict, 76% were killed. The no_tests figure was not analysed further; tz_ps_http is exercised mainly by suites outside its own package.
This diagram shows each trigger, the workflow it starts and the suites that workflow runs.
flowchart LR
PR["Pull request or push to main"]
NIGHT["Nightly, 03:00 UTC"]
WEEK["Wednesday, 00:00 UTC"]
DAILY["Daily, 04:30 UTC"]
PR --> LINT["lint.yml<br/>pre-commit, ruff, mypy, Biome, import-linter"]
PR --> BE["backend.yml"]
PR --> FEW["frontend.yml<br/>Vitest in 3 shards, typecheck, build"]
PR --> FNW["frontend-next.yml<br/>Vitest, typecheck, build"]
PR --> SDKW["frontend-sdk.yml<br/>drift, lock-check, Vitest"]
PR --> E2EW["e2e.yml<br/>frontend journeys and visual baselines"]
PR --> FNE["frontend-next-e2e.yml<br/>journeys"]
PR --> DESK["desktop.yml<br/>node, app and update specs on 3 systems"]
BE --> BT["backend-tests.yml<br/>Linux, floor Python"]
BE --> DRIFT["Registry, grammar and manifest drift, narrowing"]
BE --> MAINT["Radon maintainability gate"]
BT --> J1["libs suites, 2 shards"]
BT --> J2["tests suites, 2 shards"]
BT --> J3["bdd-git-sqlite, 4 shards"]
BT --> J4["bdd-python"]
BT --> J5["bdd-postgresql, 4 shards"]
BT --> J6["calliope shard"]
BT --> J7["pypsa-weightings notebooks"]
NIGHT --> NR["nightly-release.yml"]
NR --> BTN["backend-tests.yml<br/>Linux on every Python, Windows, macOS, plus memory"]
NR --> WHEEL["build-wheel.yml<br/>wheel smoke test"]
NR --> DESK
WEEK --> MUT["mutation-tests.yml<br/>kit tests, coverage, mutmut, kill matrix"]
DAILY --> A11Y["a11y-audit.yml<br/>Lighthouse"]
-
One definition.
backend-tests.ymldefines every backend test job once.backend.ymlandnightly-release.ymlboth call it. -
Pull requests run Linux on the floor Python. A
windowsormacoslabel on a pull request from this repository adds that leg, on the floor Python. How often the labels are used was not measured. The dedicatedmemoryjob runs only when the caller asks, and only the nightly does. -
Path filters. Each subproject's test workflow is path-filtered, and its test jobs skip a draft onto a feature branch.
lint.ymlandsecret-scan.ymlare unfiltered..github/CLAUDE.mdstates that a path-filtered job is never a required check. -
Desktop is the exception on platforms.
desktop.ymlruns on Windows, Ubuntu and macOS for each pull request that touchesdesktop/**.
Architecture-Build-CI-and-Release describes the workflows themselves.
| Workflow | Sample and date range | Result |
|---|---|---|
backend.yml |
100 runs, all on 19 Nov 2026 | 93 passed, 7 failed. The 41 full runs took a median of 19 minutes, at most 30 |
e2e.yml |
50 runs, 19 Nov 2026 | 30 passed, 3 failed, 16 skipped, 1 cancelled. One of 9 pushes to main failed. Median 9 minutes |
frontend.yml |
50 runs, 19 Nov 2026 | 31 passed, 4 failed, 15 skipped. Median 8 minutes |
desktop.yml |
50 runs, 18 to 19 Nov 2026 | 35 passed, 5 failed, 10 skipped. Median 39 minutes |
nightly-release.yml, scheduled |
27 runs, 24 Oct to 19 Nov 2026 | 12 passed, 15 failed. Finding 1 breaks these down |
mutation-tests.yml |
7 runs, 4 to 18 Nov 2026 | 0 passed whole, 4 failed, 3 cancelled. 4 of the 7 published a mutation-results artefact |
a11y-audit.yml, scheduled |
35 runs, 15 Oct to 19 Nov 2026 | 31 passed, 4 failed |
The pull-request failures were not classified, so those rows say nothing about flakiness.
Each of these was verified in the code.
-
Adapters are tested by contract on real engines. One suite runs against the JSON, git and PostgreSQL warehouses, through sync and async forms, with a real embedded PostgreSQL on every pull request. The in-memory object store used as a fake passes the same
ObjectStoreContractas the real one. -
The suite guards itself.
test_shards.pychecks that the primary CI selectors, plus the mutation-kit selector, collect every test id once; other jobs deliberately repeat scenarios on PostgreSQL and through the Python driver. Tests pin the drift jobs free of anif:. Expected failures are strict and checked for stale names. The verb allow-list has a pinned length.check_layers.pylints the acceptance layers. - It tests failure modes that are usually left out. A solve killed mid-run and recovered by a second runtime. Memory bounded for each value in a child process. A registry bump that would make stored networks unreadable. A file written by an older PyPSA. A desktop update from one packaged version to the next.
-
Stored data has upgrade tests.
backend/libs/tz_ps_datawarehouse/tests/holds 21 migration test modules, andbackend/tests/fixtures/before_snapshot_weightings/holds an older warehouse in all three formats. Their depth was not assessed. -
Journeys run the shipped shape. The
frontendjourneys drive the bundled app served bytz-ps-conductor serve, andfailOnFlakyTestsfails a test that passes only on retry. -
Numbers have an external oracle. The notebook ports and
backend/ci_scripts/compute_template_referencescompare solved values with PyPSA's own. - Reported flakes get closed. All six issues with "flaky" in the title are closed (#808, #935, #1430, #1724, #1734, #1759).
Ordered by priority. "Evidence" is verified. "Inference" is a judgement from it.
On the order of the first two. The nightly is ranked first because its evidence is repeated failure on main, including the same two jobs red for four nights running, on the platforms the desktop app ships for. Mutation testing is ranked Medium, not High: it publishes results for most packages, and its lack of a gate is a recorded design decision, not a fault. What it lacks is a complete run and a use for its output.
- Evidence, the counts. From 24 Oct to 19 Nov 2026 there were 27 scheduled runs: 12 passed and 15 failed. The first three (24 to 26 Oct) contained no backend test jobs, so 24 nights ran the test matrix and 15 of those failed. Since 6 Oct there were 45 scheduled runs and 30 passed; the earlier nights were not checked for a test matrix, so they are not evidence of test health.
- Evidence, the streaks. All 15 failures fall in three streaks: 30 Oct to 8 Nov (10 nights), 11 to 13 Nov (3) and 16 to 17 Nov (2). The last two nights passed.
-
Evidence, the failing jobs.
- 30 Oct to 2 Nov: the same two jobs failed each night,
tests-linux / test (3.14, tests)andtests-windows / test (3.13, tests). - 3 to 7 Nov: a different set each night, across the library shards on Windows and macOS and the acceptance jobs on Linux, Windows and macOS.
- 12 to 17 Nov:
tests-macos / bdd-git-sqlitetwice,tests-linux / memoryon both Pythons once, and a macOS and a Windows shard once. - Three failed nights (6, 8 and 11 Nov) had no failing backend test job: one failed in
desktop / package, two only inalert. - Of the 12 nights with a failing backend test job, Windows failed on 9, Linux on 6 and macOS on 5.
- 30 Oct to 2 Nov: the same two jobs failed each night,
-
Evidence, the reruns. A manual run on
mainpassed the same day on 3, 4, 6, 7, 12, 13, 16 and 17 Nov. Ten issues carry thenightly-testslabel for November, nine of them titled "Nightly backend tests fail", and each was closed within about a day. - Not determined. Whether each red night was a product regression, a flaky test or a runner fault. Whether each same-day green run followed a fix or was a rerun of the same commit. The four identical nights from 30 Oct point to a real failure rather than a flake, but the logs were not read.
-
Inference. A backend regression on Windows, macOS or a newer Python is normally found the night after it merges. The
windowsandmacoslabels exist to find it earlier, but only when someone applies them. -
Action. For each streak, read the first failing job's log and compare the commit with that of the same-day run that passed. That separates flake from quick fix. Then act on the result: a cheap Windows shard on every pull request if most were regressions, or fixes to the tests if most were flakes. Make the
alertjob's failure distinct from a test failure.
-
Evidence. All 7 runs between 4 and 18 Nov 2026 ended failed or cancelled. Four of them ran the
reportjob and uploadedmutation-results. In the latest, 18 of 20 packages reported: 16,157 mutants killed, 5,120 survived, and one kill matrix is complete.tz_ps_datawarehouse, the largest package, was cancelled, andtz_ps_expressionsfailed.workflow_dispatchtakes no inputs, so a manual run always starts every package.backend/mutation.tomlnamesmutation_equivalents.jsonl, and no such file is tracked. - Inference. The 5,120 survivors are the only recorded measure of whether tests discriminate, and nothing yet reads them. The agent the design describes as their consumer is a non-goal of that design.
-
Action. Add an optional package input to the workflow, validated against
mutation.toml, keeping the coverage and combine stage. Use it to gettz_ps_expressionsandtz_ps_datawarehousethrough. Then pick one small package with a complete matrix and work its survivors, to learn what the output is worth before setting any policy.
-
Evidence. There is no
fail_underand no upload step inbackend-tests.yml;--covprints one shard's part to that job's log. The weekly mutation workflow does combine and upload backend coverage, but its summary reports no percentage.frontendcoverage is not run in CI, andfrontend-nexthas no coverage script. - Action. Add a line for each package to the weekly report summary from the data it already combines. Decide on a ratchet afterwards.
-
Evidence. No suite was found that applies one set of checks to each framework that
Framework.list_frameworks()returns. The framework features and each framework package's own tests name PyPSA or Calliope. Adding a framework lists the same gap. - Inference. A contract that a new framework breaks is caught only by tests its author thinks to write.
-
Action. Add a parametrised suite over
Framework.list_frameworks()that checks, for each:list_network_problemsdoes not raise,build_componentround-trips, andrevisionis stable.
-
Evidence.
.github/CLAUDE.mdallows only the unfilteredlint.ymlandsecret-scan.ymlto be required.mainhas no classic branch protection. Two organisation rulesets are active; which checks they require was not verified. - Inference. If the rulesets follow the convention, every test result gates a merge by convention and the pr-steward routine alone.
- Action. Add one unfiltered gate job that reports the result of whichever filtered workflows ran, and require it.
-
Evidence. 57 scenarios are in the four-layer suite and 1,251 in the old one. The old suite runs through
TestClient, so it does not test the deployed process. Its 94 step modules share one namespace, where a duplicate name silently overwrites another.backend/tests/component/does not exist. -
Inference. HTTP status and slug checks are likely duplicated across the old features,
backend/tests/contract/andtz_ps_http's own tests. The amount was not measured. -
Action. Set a stop point or a timebox for the conversion. Now, add a collection-time check that fails on a duplicate step wording or fixture name in
backend/tests/steps/.
-
Evidence. 20 journey call sites against 90. No visual baselines against 28. One worker on one shared warehouse in a fixed temporary folder, which the config's own comments call a shortcut. Retries without
failOnFlakyTests. The daily Lighthouse audit buildsfrontend, notfrontend-next. Unit test density is similar in both. -
Context.
frontend-next/CLAUDE.mdsays releases still build fromfrontend/. -
Action. Before
frontend-nextis merged intofrontend/: port the per-worker server fixture, setfailOnFlakyTests, point the audit at it, and write the list of journeys it must match.
-
Evidence. There are 14
pytest.skip("this backend ...")calls inbackend/libs/tz_ps_datawarehouse/tests/: 6 intest_run_values_contract.py, 4 intest_added_run_values_contract.py, 3 inconftest.pyand 1 intest_warehouse_derived_values_change.py. Eight skip a guarantee the backend does not keep: run values (6) and rename (2). The other six have a premise that needs a particular backend: three test the refusal on a backend that does keep run values, two need a document store, one needs series. The rule inbackend/CLAUDE.mdis written aboutkeeps_every_version, which the suite does assert. Separately, 55 of the 66 PostgreSQL expected failures are one missing capability. - Inference. A skip does not fail when the backend gains the capability. The strict expected-failure list does.
- Action. Replace the run-value and rename skips with assertions of the refusal. Track the 66 as a burn-down on the PostgreSQL work.
-
Evidence. No benchmark or load-test files are tracked. Neither
hypothesisnorfast-checkis a dependency. Specific risks are covered: the memory bounds,test_import_at_scale.py, path encoding (test_paths.py), unreadable and malformed imports (backend/tests/features/network_file_imports.feature) and path redaction in problem documents (backend/libs/tz_ps_http/tests/test_problem_detail.py). Security cover beyond those was not surveyed. -
Inference. A latency regression would show only as a slower CI job.
frontend/CLAUDE.mdstates that the repository will be public, which raises the value of hostile-input tests. - Action. Measure the gaps in the existing negative tests first. Then add budgets that count operations (git calls or SQL statements) for the hot reads, and property tests for the expression parser and the path encoders.
-
Evidence. 72
sleep(sites, many of them child scripts holding a process open. Three steps insteps/run_cancellations.pyandsteps/api_lifecycle.pysleep a fixed time, against the waits rule.desktop/tests/app.spec.tshas twowaitForTimeout(500)calls. Closed issues #1430 and #1952 were both failures under load. -
Action. Extend the waits rule to
libs/*/tests. Replace the three steps and the two desktop timeouts with waits on a condition.
-
Evidence. 32 of 39 are skipped without
--pypsa-coverage, and no schedule runs them.docs/examples/pypsa/COVERAGE.mdrecords no run date, by rule. - Action. Run them weekly on a schedule and open an issue on failure, as the nightly does.
-
Evidence. 100
backend.ymlruns in about ten and a half hours on 19 Nov 2026, each with about 15 jobs.tz_ps_datawarehouseis 39% of collected backend tests. Journeys run Chromium at one viewport, by design. -
Action. Review the slowest tests from
--durations=30, which each job already prints. No action on browsers now.
| Step | Finding | Priority | Size |
|---|---|---|---|
| Classify each nightly streak from its first failing log and the same-day green run | 1 | High | Small |
| Act on that: a Windows shard on pull requests, or fix the flaky tests | 1 | High | Medium |
| Add a package input to the mutation workflow, and get the two missing packages through | 2 | Medium | Small |
| Work the survivors of one package with a complete matrix | 2 | Medium | Medium |
| Add coverage for each package to the weekly summary | 3 | Medium | Small |
| Add a conformance suite over every installed framework | 4 | Medium | Medium |
| Add a single required gate job | 5 | Medium | Small |
| Fail collection on a duplicate step wording or fixture name | 6 | Medium | Small |
Write the frontend-next journey parity list, and port the server fixture |
7 | Medium | Medium |
| Replace the run-value and rename skips with assertions | 8 | Medium | Small |
| Schedule the PyPSA coverage notebooks weekly | 11 | Low | Small |
| Remove the fixed sleeps the waits rule forbids | 10 | Low | Small |
-
backend/mutation.tomlnames an equivalents register,mutation_equivalents.jsonl, that is not in the repository. -
.github/workflows/mutation-tests.ymltakes no inputs, so one package cannot be run alone in CI. -
backend/tests/test_import_at_scale.pyandtest_reads_the_file_itself.pyskip cases when a local fixture file is absent, so those cases never run in CI. -
frontend-next/playwright.config.tsmarks two behaviours as shortcuts: the warehouse outlives the run, and a second concurrent run can wipe it. - Not verified: the wiki walkthroughs, the depth of the migration tests, and which checks the organisation rulesets require.
Using the app
Architecture
- Overview
- Python API
- Domain model
- Backend core
- Composition root and config
- Expression language internals
- Storage
- Execution
- Imports and exports
- Workflow engine
- HTTP API and contracts
- Frontend and desktop
- Build, CI and release
Contributing