Skip to content

test: add integration and functional test suite#218

Merged
smlloyd merged 3 commits intomasterfrom
tests-rearange
Feb 24, 2026
Merged

test: add integration and functional test suite#218
smlloyd merged 3 commits intomasterfrom
tests-rearange

Conversation

@smlloyd
Copy link
Copy Markdown
Member

@smlloyd smlloyd commented Feb 24, 2026

  • Refactor tests/conftest.py with grouped fixtures and shared helpers
  • Add integration tests for core modules: event, project, seismogram, station, snapshot, model relationships (cascade deletes)
  • Add functional CLI tests: basic ops, project lifecycle, parameters, snapshots, sample data
  • Split TestProjectLifecycle into file-backed (subprocess) and in-memory (in-process) variants
  • Fix print_project_info to display 'in-memory database' instead of ':memory:' as the project file label
  • All tests use in-process cli fixture with monkeypatched engine; subprocess only used where real file I/O is required
  • Short-ID variants included for all UUID-accepting CLI commands

📚 Documentation preview 📚: https://aimbat--218.org.readthedocs.build/en/218/

- Refactor tests/conftest.py with grouped fixtures and shared helpers
- Add integration tests for core modules: event, project, seismogram,
  station, snapshot, model relationships (cascade deletes)
- Add functional CLI tests: basic ops, project lifecycle, parameters,
  snapshots, sample data
- Split TestProjectLifecycle into file-backed (subprocess) and
  in-memory (in-process) variants
- Fix print_project_info to display 'in-memory database' instead of
  ':memory:' as the project file label
- All tests use in-process cli fixture with monkeypatched engine;
  subprocess only used where real file I/O is required
- Short-ID variants included for all UUID-accepting CLI commands
Copilot AI review requested due to automatic review settings February 24, 2026 19:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the test suite into clearer unit/integration/functional layers and updates core/CLI code to support those tests (including SQLite FK enforcement, richer JSON/table dumping, and CLI command reshaping).

Changes:

  • Replaces legacy mixed-scope tests with new unit + integration suites (core modules, models/I/O, types) and functional CLI coverage.
  • Updates core modules to use JSON→table rendering and adds richer JSON dump helpers (stations with counts, snapshots dump structure, event reads).
  • Adjusts CLI wiring (lazy subcommand registration, moves/changes some commands) and enforces SQLite foreign keys on connect.

Reviewed changes

Copilot reviewed 63 out of 67 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/utils/test_utils.py Removes legacy utils tests (replaced by new unit/functional coverage).
tests/unit/utils/test_uuid.py Adds unit tests for UUID resolution/shortening.
tests/unit/utils/test_sampledata.py Adds unit tests for sample data download/delete with mocked network.
tests/unit/utils/test_json.py Adds unit tests for JSON-to-rich-table rendering helper.
tests/unit/test_config.py Adds unit tests for Settings defaults and settings table output.
tests/unit/test_app.py Expands unit tests/docstrings for CLI entrypoint behaviour.
tests/unit/models/test_sqlalchemy.py Adds tests for custom SQLAlchemy types (pandas timestamp/timedelta).
tests/unit/io/test_sac.py Adds unit tests for SAC I/O helpers (read/write + model creation).
tests/unit/cli/test_common.py Adds unit tests for CLI common params/hints/decorator.
tests/unit/aimbat_types/test_pydantic.py Adds tests for custom Pydantic types and validators.
tests/test_typing.py Removes legacy typing consistency tests (superseded by new coverage).
tests/test_station.py Removes legacy station tests (replaced by integration/functional suites).
tests/test_snapshot.py Removes legacy snapshot tests (replaced by integration suite).
tests/test_settings.py Removes legacy settings tests (replaced by unit config tests).
tests/test_seismogram.py Removes legacy seismogram tests (replaced by integration suite).
tests/test_project.py Removes legacy project tests (replaced by integration/functional suites).
tests/test_models.py Removes legacy model tests (replaced by integration datasource tests).
tests/test_io.py Removes legacy I/O tests (replaced by unit/integration SAC tests).
tests/test_iccs.py Removes legacy ICCS tests (coverage likely moved elsewhere).
tests/test_event.py Removes legacy event tests (replaced by integration suite).
tests/test_data.py Removes legacy data ingestion tests (replaced by integration suite).
tests/lib/test_lib_common.py Removes legacy UUID lib tests (replaced by unit uuid tests).
tests/integration/test_station.py Adds integration coverage for station operations/printing/JSON.
tests/integration/test_snapshots.py Adds integration coverage for snapshot lifecycle + rollback + dumps.
tests/integration/test_seismogram.py Adds integration coverage for seismogram operations/params/plotting.
tests/integration/test_project.py Adds file-backed integration tests for project lifecycle/info.
tests/integration/test_event.py Adds integration coverage for event ops + parameter dumps/printing.
tests/integration/test_datasource_sac.py Adds integration coverage for SAC↔model mapping + data proxying.
tests/integration/test_data_io.py Adds integration coverage for data add/dry-run/table dump/printing.
tests/integration/test_active_event.py Adds integration coverage for active event get/switch/set-by-id.
tests/functional/test_cli_sampledata.py Adds slow functional CLI tests for sampledata download/delete.
tests/functional/test_cli_project.py Adds subprocess functional CLI tests for file-backed project ops.
tests/cli/test_cli_common.py Removes legacy CLI common test (replaced by unit/cli suite).
tests/baseline/tests.test_seismogram.TestSeismogramPlot.test_lib_plotseis_mpl.png Adds/updates matplotlib baseline for plot tests.
tests/init.py Keeps tests package initialisation for structured test discovery.
src/aimbat/utils/_checkdata.py Removes checkdata functionality (and related CLI).
src/aimbat/utils/_active_event.py Removes utils-layer active event helper (moved to core).
src/aimbat/utils/init.py Stops exporting removed utils modules; keeps remaining exports.
src/aimbat/db.py Enforces SQLite foreign keys via PRAGMA on every connection.
src/aimbat/core/_station.py Adds active-event station retrieval + station counts; refactors table rendering.
src/aimbat/core/_snapshot.py Refactors snapshot querying/printing; adds multi-table snapshot dump structure.
src/aimbat/core/_seismogram.py Adds seismogram-parameter dump helper; adjusts table NPTS computation.
src/aimbat/core/_project.py Improves project creation triggers + in-memory label in info output.
src/aimbat/core/_iccs.py Switches active-event import to core module (avoids utils dependency).
src/aimbat/core/_event.py Refactors event dump/print to JSON-table approach; uses read DTOs.
src/aimbat/core/_data.py Renames/extends ingestion API (add_data_to_project) incl. dry-run reporting.
src/aimbat/core/_active_event.py Introduces core active-event get/set helpers (replacing utils).
src/aimbat/core/init.py Exposes core active-event helpers from package init.
src/aimbat/cli/_utils/app.py Removes checkdata CLI; adds utils settings command.
src/aimbat/cli/_snapshot.py Updates snapshot dump CLI to new dump function.
src/aimbat/cli/_data.py Updates data add CLI parameters; adds dry-run flag; calls new core API.
src/aimbat/app.py Refactors root CLI registration to string-based subcommand references.
src/aimbat/aimbat_types/_pydantic.py Tightens None-handling/serialisation for timedelta/timestamp annotations.
src/aimbat/_config.py Refactors settings printing to use JSON→table helper.
pyproject.toml Adds pytest markers configuration.
flake.nix Updates dev shell inputs ordering/additions.
Makefile Splits test targets (tests vs tests-full) and adds slow-test exclusion.
.gitignore Adds ignores for auxiliary tool files.
.github/copilot-instructions.md Expands contributor instructions (tests, architecture, conventions).

Comment thread src/aimbat/core/_data.py Outdated
Comment thread src/aimbat/core/_data.py Outdated
Comment thread src/aimbat/core/_station.py
Comment thread src/aimbat/core/_seismogram.py
Comment thread src/aimbat/app.py
Comment thread src/aimbat/cli/_data.py Outdated
Comment thread tests/unit/utils/test_uuid.py Outdated
…ompatibility

- Use glob('*.bhz', case_sensitive=False) in conftest to match SAC files
  regardless of extension casing on any platform
- Use Path.as_posix() when joining file paths into CLI command strings to
  avoid shlex stripping backslashes from Windows paths
- Fix print_project_info to display 'in-memory database' instead of ':memory:'
…epoint handling

- Move tests/unit/utils/test_uuid.py to tests/integration/test_uuid.py;
  drop local session fixture in favour of conftest patched_session
- Use nested.rollback() instead of session.rollback() in add_data_to_project
  dry-run path to avoid rolling back the outer transaction
- Move session.commit() outside begin_nested() context for clarity
- Snapshot existing IDs before entering the savepoint
- Fix missing session arg in add_data_to_project docstring
@smlloyd smlloyd merged commit 458bd3f into master Feb 24, 2026
21 checks passed
@smlloyd smlloyd deleted the tests-rearange branch February 24, 2026 21:24
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 98.55072% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.51%. Comparing base (3a889ed) to head (e2a5f03).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/aimbat/db.py 66.66% 3 Missing ⚠️
src/aimbat/aimbat_types/_pydantic.py 80.00% 1 Missing ⚠️
src/aimbat/core/_project.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
+ Coverage   88.04%   93.51%   +5.46%     
==========================================
  Files          46       45       -1     
  Lines        1890     1849      -41     
==========================================
+ Hits         1664     1729      +65     
+ Misses        226      120     -106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants