wrolpi/modules/inventory/test
Roland 6a46cfd17d
Add manual import + backup Restore/Merge/Overwrite for inventory configs
Inventories are a config-only MultiFileConfig (config/inventory/<slug>.yaml) and
were not reachable by the admin config Restore UI, so there was no way to re-import
a hand-edited/copied-in file or restore an inventory from its daily backup.

Backend:
- MultiFileConfig gains generic helpers: get_backup_dates(slug)/_get_backup_file
  (surface the daily config/backup/<subdir>/<slug>-DATE.yaml files) and reimport()
  (rebuild the in-memory store from disk; picks up hand-edits and copied-in files,
  drops files deleted on disk).  backup_date is constrained to YYYYMMDD so it cannot
  traverse out of the backup directory.
- InventoriesConfig.preview_restore/apply_restore: overwrite replaces the whole
  inventory; merge unions items by id (keeps current fields and existing items).
  The pre-restore state is backed up automatically, so a restore is undoable.
- API: POST /inventory/reimport, GET /inventory/<slug>/backups,
  POST /inventory/<slug>/restore/preview, POST /inventory/<slug>/restore.

Frontend:
- New InventoryImportModal (opened from a Restore button in the Inventory toolbar):
  Re-import from disk, plus a dated-backup table with per-row Merge/Overwrite that
  previews the change before applying.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 16:28:11 -06:00
..
__init__.py A new start 2021-11-01 16:43:09 -06:00
test_api.py Add manual import + backup Restore/Merge/Overwrite for inventory configs 2026-06-19 16:28:11 -06:00
test_catalog.py Add a recommended Food Storage example, a Ration tab, and a supply planner 2026-06-19 12:40:30 -06:00
test_inventory.py Add manual import + backup Restore/Merge/Overwrite for inventory configs 2026-06-19 16:28:11 -06:00
test_migration.py Rebuild Inventory as a config-only system with food catalog and calculators 2026-06-14 17:14:54 -06:00
test_multifile_config.py Add manual import + backup Restore/Merge/Overwrite for inventory configs 2026-06-19 16:28:11 -06:00