Repository navigation
test: reorganise tests/ into category folders (#167) - #221
Merged
Merged
Conversation
tests/ held 41 Python test files in one flat folder, so there was no way to run one category and new tests landed unclassified. They are now grouped by what a test needs: unit/ no database, no network system/ the API against a live PostgreSQL (22 files) system_integration/ whole pipeline, every environment, parity (3 files + environments/) performance/, accessibility/, uat/ placeholders, each a package Same 379 tests: the set of collected test ids is identical before and after, and the full suite, evals and SQL suites give the same results. What the move needed: - 20 files computed paths from __file__; they now use parents[2] (tests/<category>/), and the snapshot directory stays at tests/snapshots. test_password_reset's import of test_accounts and the environments package imports use the new module paths. - pytest.ini registers system, sit, performance, accessibility and uat. conftest.py adds the marker for a test's folder automatically, so `-m system` and `-m "not accessibility"` agree with the layout. `unit` stays explicit: the free tier and the Windows job select on it. - scripts/health_check.py globbed tests/test_*.py non-recursively and would have failed `make health`; it now searches recursively. select_tests.py matched the fragment tests/test_ and now maps each category folder. run_qa.ps1 named two test files by path (edited in bytes, CRLF kept). - scripts/lint.sh listed 14 of the 38 test files by hand; it now finds every Python file under tests/ (50). That surfaced 40 cosmetic flake8 findings in 10 files, fixed. - Live docs and code comments that name test paths are updated. Historical records (bug reports, audits, handoffs) are left as written. - docs/TEST_CASES.md regenerated for the new paths. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBrxqChRJtxdvSpFhiUWUy
- conftest.py: the four shared fixtures from the issue for tests that drive the live API: live_api (starts the API, self.client), destructive_enabled, registry_cleanup and te_org_cleanup. unittest classes can't take fixture arguments, so each also sets an attribute and is used with @pytest.mark.usefixtures. - Two worked examples: system/test_failed_uploads.py drops its setUpClass/tearDownClass and now cleans up the registry rows it creates (it never did); one test in system/test_review.py loses a try/finally. The other 19 files that start the API by hand are not converted: that would bury the move in a refactor. - Makefile: test-unit, test-system, test-sit, test-performance, test-accessibility and test-uat. An empty category (pytest exits 5) reports that and succeeds. They use `python3 -m pytest` like the scripts do. - tests/README.md: the layout, where a new test goes, how to run one category, the fixtures and the path convention. requirements-dev.txt is not touched: playwright and axe-playwright-python are added with the accessibility job (#168), which is the first thing to use them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBrxqChRJtxdvSpFhiUWUy
1 task done
#220 added tests/test_te_reupload_registry.py at the top of tests/, where this layout would leave it unclassified; moved to tests/system/ (it drives the API against PostgreSQL) and the docstring that names its path updated. The test catalogue was the only conflict: taken from main and regenerated. Full pytest suite passes against a freshly deployed PostgreSQL 16. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBrxqChRJtxdvSpFhiUWUy
1 task done
amar-python
marked this pull request as ready for review
November 9, 2026 14:44
amar-python
pushed a commit
that referenced
this pull request
Nov 9, 2026
The tests moved to tests/unit/ with the reorganisation; Git carried the control's tests across the rename. One path in them computed the repo root with parent.parent and is now parents[2]. The generated test catalogue was the only conflict: taken from main and regenerated with scripts/test_catalogue.py. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBrxqChRJtxdvSpFhiUWUy
amar-python
pushed a commit
that referenced
this pull request
Nov 9, 2026
…ace the new tests The reorganisation of tests/ (#221) is on main. Git followed the renames of test_migrations.py and test_tenant_isolation.py; the three test files this branch adds are moved to the homes #221 suggested: test_prod_db_naming.py to unit/, test_tenant_te_migrations.py and test_type_provenance.py to system/. Paths a text merge cannot see are fixed: the repo root is parents[2] in the two moved files that compute it, and in test_tenant_isolation.py, whose _ALEMBIC_INI line (added here for #195) still pointed at tests/alembic.ini. Two references to the old path (te0002's docstring, docs/TENANT_SCHEMA_MIGRATIONS.md) are updated. The generated test catalogue was the only conflict: regenerated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBrxqChRJtxdvSpFhiUWUy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/held 41 Python test files in one folder, so there was no way to run a single category and new tests landed unclassified. They are now grouped by what a test needs to run:unit/system/system_integration/environments/(4)performance/,accessibility/,uat/Same tests. At the time of the move the set of collected test ids was identical before and after (379, diffed, not just counted), and the full suite, evals and SQL suites gave the same results.
mainhas since added tests (#215); the one new file,test_te_reupload_registry.py, is placed insystem/as part of the merge below.Commits: the move and everything it requires; the additive parts (fixtures, make targets, README); and a merge of
main. 39 files show as renames (git diff -M); the four tinytest_env_*files show as delete + add because they are 6 lines each.What the move needed
__file__; they now useparents[2], and the snapshot directory stays attests/snapshots. The cross-test import (test_password_reset→test_accounts) and the environments package imports use the new module paths. (I broke the snapshot path once while doing this and caught it in the diff review.)scripts/health_check.pyglobbedtests/test_*.pynon-recursively, somake health(run by CI's free-tier job) would have failed. Now recursive.select_tests.pymatched the fragmenttests/test_; it now maps each category folder.scripts/run_qa.ps1named two test files by path (edited in bytes, CRLF kept).scripts/lint.shlisted 14 of the 38 test files by hand. It now finds every Python file undertests/(50). That surfaced 40 cosmetic flake8 findings in 10 files, fixed.pytest.iniregisterssystem,sit,performance,accessibility,uat;conftest.pyadds the marker for a test's folder automatically, so-m systemand-m "not accessibility"agree with the layout.unitstays explicit (the free tier and the Windows job select on it).Added
live_api,destructive_enabled,registry_cleanup,te_org_cleanup) for tests that drive the live API. Two worked examples:system/test_failed_uploads.pydrops its setUp/tearDown boilerplate and now cleans up the registry rows it creates (it never did); one test insystem/test_review.pyloses a try/finally. After running them, 0allfail_*registry rows and 0TE_REV_*organisations remain.make test-unit | test-system | test-sit | test-performance | test-accessibility | test-uat. An empty category reports that and succeeds.tests/README.md: the layout, where a new test goes, the fixtures.Not done
requirements-dev.txtis not touched. The issue listsplaywrightandaxe-playwright-python, but they are only used by the accessibility job (Add accessibility CI job (Playwright + axe-core WCAG 2.1 AA scans) #168, PR ci: accessibility job, Playwright + axe-core WCAG 2.1 AA scans (#168) #222), which adds them in a separaterequirements-a11y.txt.system/also hold database-free classes (markedunit). They live in the category of their heaviest need and still run in the free tier, because it selects on the marker. So-m unitand-m systemoverlap by those classes; the README explains it.Merged with main, and what other open PRs add
mainmoved while this was open (#215 changedupload_te's tests and addedtests/test_te_reupload_registry.py), so the PR stopped merging cleanly.mainis merged in: Git followed the rename oftest_api_coverage.pyon its own; the new flat file is moved totests/system/(and the one docstring that names its path updated); the generateddocs/TEST_CASES.mdis regenerated. The full suite passes on the merged tree against a freshly deployed PostgreSQL 16.Merge order matters for other PRs. I simulated the merge with each. #204 and #208 merge cleanly. #213 conflicts only in the generated
docs/TEST_CASES.md(regenerate withpython3 scripts/test_catalogue.py); Git followed the renames throughtest_migrations.pyandtest_tenant_isolation.py.Those PRs add test files at the top of
tests/, which this layout leaves unclassified. Suggested homes once they land:test_prod_db_naming.py→unit/,test_docker_image_secrets.py→unit/,test_tenant_te_migrations.py,test_type_provenance.py,test_runtime_role_per_env.py→system/. Nothing enforces the layout, so a straggler is harmless but unclassified until moved.Verification (local, PostgreSQL 16, all four environments deployed)
Collected test ids: identical to the 379 on
mainat the time of the move (test_oidc.pyexcluded locally only: an unrelatedcffiimport problem in this sandbox)On a clean database, in CI order:
evals/runner.py --tiers p,i,s,e26/26;tests/run_tests.sh dev test159/159 each; full pytest passes (also after the merge ofmain); coverage floors hold (csv_parse 82.1% ≥ 79, dynamic_loader 87.3% ≥ 84, te_loader 97.3% ≥ 96)make lintclean (50+ test files),make health89 passed,make test-unit122 passed,test_catalogue.py --checkcurrentThe database-free marker set (the Windows job's selection) passes: 148 tests
CI green on the current head (1f195a0): free tier, integration (postgres service) and the Windows
python-validator-testsjob.Generated by Claude Code