test: add integration and functional test suite#218
Merged
Conversation
- 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
Contributor
There was a problem hiding this comment.
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). |
…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
Codecov Report❌ Patch coverage is
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. |
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.
📚 Documentation preview 📚: https://aimbat--218.org.readthedocs.build/en/218/