Consolidating test database creation
Addresses #235
Refactored testing database generation to first load a central schema and then load data only SQL files
Summary by CodeRabbit
-
Tests
- Centralized unit-test DB creation: new test constants and a single build helper to generate databases from one canonical source, simplifying variations and refresh flow.
-
Configuration
- Streamlined test TOML files: removed legacy I/O/solver flags, added top-level time_sequencing and reserve_margin, and enabled myopic timing options where applicable.
-
Test Data
- Seed files converted to idempotent REPLACE INTO upserts and added a comprehensive utopia_data.sql as the single canonical dataset.
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Centralized test DB construction was added to tests/conftest.py with TEST_* path constants and a _build_test_db helper. Test DB refresh/creation now uses centralized REPLACE-based seed files (including new tests/testing_data/utopia_data.sql) and per-variation modifications. Many TOML test configs were simplified and SQL fixtures converted to idempotent upserts.
Changes
| Cohort / File(s) | Summary |
|---|---|
Test infrastructure refactor tests/conftest.py |
Added TEST_DATA_PATH, TEST_OUTPUT_PATH, SCHEMA_PATH and _build_test_db(db_file, data_scripts, modifications); refactored refresh_databases and create_unit_test_dbs to build DBs from centralized SQL seeds instead of ad-hoc per-db SQL construction. |
Test configs (standardization) tests/testing_configs/* tests/testing_configs/config_annualised_demand.toml, tests/testing_configs/config_emissions.toml, tests/testing_configs/config_link_test.toml, tests/testing_configs/config_materials.toml, tests/testing_configs/config_mediumville.toml, tests/testing_configs/config_seasonal_storage.toml, tests/testing_configs/config_storageville.toml, tests/testing_configs/config_survival_curve.toml, tests/testing_configs/config_test_system.toml, tests/testing_configs/config_utopia.toml, tests/testing_configs/config_utopia_gv.toml, tests/testing_configs/config_utopia_myopic.toml |
Removed legacy top-level keys (input_database, output_database, neos, solver_name, save_excel, save_duals, save_lp_file), stripped large commented blocks, added/standardized top-level time_sequencing and reserve_margin, and normalized [MGA]/[myopic] entries (removed inline comments; added view_depth/step_size where applicable). |
Test data: REPLACE-based seeds & new utopia seed tests/testing_data/* tests/testing_data/annualised_demand.sql, tests/testing_data/emissions.sql, tests/testing_data/mediumville.sql, tests/testing_data/seasonal_storage.sql, tests/testing_data/simple_linked_tech.sql, tests/testing_data/storageville.sql, tests/testing_data/survival_curve.sql, tests/testing_data/utopia_data.sql, temoa/tutorial_assets/utopia.sql |
Converted fixture scripts from CREATE TABLE / transactional INSERTs to idempotent REPLACE INTO upsert-style seeds (removed BEGIN/COMMIT and DDL). Added consolidated utopia_data.sql seed; minor numeric literal formatting change in temoa/tutorial_assets/utopia.sql. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- TemoaProject/temoa#193 — Overlaps on test path/output handling and migration to file-relative/test-path constants and helpers.
- TemoaProject/temoa#190 — Related schema/data migration work; both change test data seeds and introduce consolidated schema/seed handling.
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Consolidating test database creation' accurately and concisely describes the main objective of the PR, which is to refactor database creation to use a centralized schema and unified data-loading approach. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.