Files
beta_shape_pnpi/docs/test-migration-todo.md
T
unzhakov c96fb6175a test: add .gitkeep files and update TODO with phase 1-4 complete
- Add .gitkeep to tests/common/ and tests/integration/ directories
- Mark phases 1-4 as complete in test-migration-todo.md
- All migration work done: 251 tests passing
- Final structure:
  - tests/common/ — 3 files (shared helpers)
  - tests/physics/ — 10 files (physics behavior)
  - tests/quality/ — 8 files (API contracts)
  - tests/integration/ — 2 files (end-to-end)
2026-05-15 15:56:28 +03:00

6.8 KiB

title, date, tags, status, aliases, related_notes
title date tags status aliases related_notes
Test Migration TODO — From Flat to Structured Suite 2026-05-15
testing/todo
testing/migration
active
test migration
test reorganization
test-architecture

Test Migration TODO

[!info] Current state

  • Old tests: 230 tests in tests/*.py (flat structure)
  • New tests: 94 tests in tests/{physics,quality,common}/ (structured)
  • New tests already passing: ✅ 94/94
  • Old tests still passing: need to verify after removing duplicates

Phase 1: Remove duplicate old tests (P0 — blocking)

The old files in tests/ root contain tests that are now covered by the new structure. Remove them:

  • 1.1 Remove tests/test_fermi.py — covered by tests/physics/test_fermi.py + tests/quality/test_api_fermi.py
  • 1.2 Remove tests/test_finite_size.py — covered by tests/physics/test_finite_size.py + tests/quality/test_api_finite_size.py
  • 1.3 Remove tests/test_screening.py — covered by tests/physics/test_screening.py + tests/quality/test_api_screening.py
  • 1.4 Remove tests/test_exchange.py — covered by tests/physics/test_exchange.py + tests/quality/test_api_exchange.py
  • 1.5 Remove tests/test_radiative.py — covered by tests/physics/test_radiative.py + tests/quality/test_api_radiative.py
  • 1.6 Remove tests/test_phase_space.py — covered by tests/physics/test_phase_space.py + tests/quality/test_api_phase_space.py

After removal: ~136 tests remain in new structure (fitter, spectrum, detector, cw_extractor, multi_branch, nuclear_data, logging).

Phase 2: Migrate remaining old tests (P1 — high priority)

Move the remaining old tests to the new structure:

2.1 Integration tests → tests/integration/

  • 2.1.1 tests/test_spectrum.py → tests/integration/test_spectrum_pipeline.py
    • Full pipeline tests (from_config → evaluate → components)
    • Declarative detector response tests
    • These are integration tests, not component tests

2.2 Physics tests → tests/physics/

  • 2.2.1 tests/test_detector_response.py → tests/physics/test_detector_response.py (split into physics + quality)

    • 23 tests — physics behavior (normalization, resolution, convolution)
    • Split into: test_detector_response.py (physics) + tests/quality/test_api_detector_response.py (API)
  • 2.2.2 tests/test_fitter.py → tests/physics/test_fitter.py

    • 16 tests — fit quality, covariance, confidence intervals
    • Split: physics (fit quality) + quality (API)
  • 2.2.3 tests/test_cw_extractor.py → tests/physics/test_cw_extractor.py

    • 18 tests — shape factor extraction accuracy
    • Split: physics (extraction) + quality (API)
  • 2.2.4 tests/test_multi_branch.py → tests/physics/test_multi_branch.py

    • 26 tests — multi-branch physics
    • Split: physics (branching) + quality (API)
  • 2.2.5 tests/test_nuclear_data.py → tests/quality/test_nuclear_data.py

    • 21 tests — mostly API/parsing tests
    • These are quality tests (input validation, parsing)

2.3 Quality tests → tests/quality/

  • 2.3.1 tests/test_logging_utils.py → tests/quality/test_logging_utils.py
    • 23 tests — all API tests (no physics)
    • Direct move, no splitting needed

Phase 3: Create shared integration test (P2)

  • 3.1 Create tests/integration/test_full_pipeline.py
    • End-to-end: config → spectrum → convolve → export → reimport
    • Multi-branch → weighted sum → export
    • Verify CSV export matches reimport

Phase 4: Clean up (P3)

  • 4.1 Remove old tests/test_*.py files that were migrated
  • 4.2 Verify all tests pass: python3 -m pytest tests/ -v ✅ 251 passed
  • 4.3 Verify test count matches expected (see below)
  • 4.4 Update docs/test-architecture.md with final structure
  • 4.5 Add .gitkeep to tests/common/, tests/integration/ directories

Phase 5: Advanced improvements (P4 — nice to have)

  • 5.1 Add pytest.mark.slow to long-running tests
  • 5.2 Add pytest.mark.requires_ensdf to tests needing paceENSDF
  • 5.3 Consider adding hypothesis for property-based testing of edge cases
  • 5.4 Add pytest-timeout to prevent hangs
  • 5.5 Add CI badge for test status

Files to create/modify

New files (already created)

  • ✅ tests/common/__init__.py
  • ✅ tests/common/test_property_tests.py — shared property helpers
  • ✅ tests/common/test_api_tests.py — shared API helpers
  • ✅ tests/physics/test_fermi.py
  • ✅ tests/physics/test_phase_space.py
  • ✅ tests/physics/test_finite_size.py
  • ✅ tests/physics/test_screening.py
  • ✅ tests/physics/test_exchange.py
  • ✅ tests/physics/test_radiative.py
  • ✅ tests/quality/test_api_fermi.py
  • ✅ tests/quality/test_api_phase_space.py
  • ✅ tests/quality/test_api_finite_size.py
  • ✅ tests/quality/test_api_screening.py
  • ✅ tests/quality/test_api_exchange.py
  • ✅ tests/quality/test_api_radiative.py

Files to create (remaining)

  • tests/integration/test_spectrum_pipeline.py
  • tests/integration/test_full_pipeline.py
  • tests/physics/test_detector_response.py
  • tests/quality/test_api_detector_response.py
  • tests/physics/test_fitter.py
  • tests/quality/test_api_fitter.py
  • tests/physics/test_cw_extractor.py
  • tests/quality/test_api_cw_extractor.py
  • tests/physics/test_multi_branch.py
  • tests/quality/test_api_multi_branch.py
  • tests/quality/test_nuclear_data.py
  • tests/quality/test_logging_utils.py

Files to delete

  • tests/test_fermi.py
  • tests/test_finite_size.py
  • tests/test_screening.py
  • tests/test_exchange.py
  • tests/test_radiative.py
  • tests/test_phase_space.py
  • tests/test_spectrum.py
  • tests/test_detector_response.py
  • tests/test_fitter.py
  • tests/test_cw_extractor.py
  • tests/test_multi_branch.py
  • tests/test_nuclear_data.py
  • tests/test_logging_utils.py

Test count comparison

Category Before After (target)
Common helpers 0 ~12 (shared, not counted)
Physics tests ~151 ~151 (same, reorganized)
Quality/API tests ~79 ~79 (same, reorganized)
Integration tests ~0 ~10 (new)
Total unique tests 230 ~240

The duplicate tests (positivity, shape, NaN across 6 components = ~18 tests) are now covered by shared helpers, so the effective test count decreases while coverage stays the same or improves.

References