Files
nifodea/tests/test_excel_sync.py
T
oqyude feb77ef217 T1: restructure to domain/application/infrastructure + schema version 1
- Move cashflow_model/ -> domain/
- Move engine/ -> application/
- Move cli/, sync/, ai/ -> infrastructure/
- Update all imports across codebase and tests
- Add version=1 to FinancialModel.to_dict() with migration hook in from_dict
- Update pyproject.toml: cf entry point and packages.find

Tests: 63/63 pass.
2026-10-08 16:34:10 +03:00

50 lines
1.7 KiB
Python

from pathlib import Path
from domain import FinancialModel
from infrastructure.sync.excel_sync import ExcelSync, SyncError
class TestExcelSync:
def test_export_creates_file(self, sample_model, tmp_path: Path):
sync = ExcelSync()
p = tmp_path / "test.xlsx"
sync.export_model(sample_model, p)
assert p.exists()
def test_export_import_roundtrip(self, sample_model, tmp_path: Path):
sync = ExcelSync()
p = tmp_path / "roundtrip.xlsx"
sync.export_model(sample_model, p)
loaded = sync.import_model(p)
assert len(loaded.accounts) == len(sample_model.accounts)
assert len(loaded.transactions) == len(sample_model.transactions)
assert len(loaded.recurring) == len(sample_model.recurring)
assert len(loaded.assets) == len(sample_model.assets)
assert len(loaded.liabilities) == len(sample_model.liabilities)
assert len(loaded.exchange_rates) == len(sample_model.exchange_rates)
def test_roundtrip_preserves_base_currency(self, tmp_path: Path):
sync = ExcelSync()
model = FinancialModel(base_currency="EUR")
p = tmp_path / "eur_model.xlsx"
sync.export_model(model, p)
loaded = sync.import_model(p)
assert loaded.base_currency == "EUR"
def test_import_missing_file(self):
sync = ExcelSync()
try:
sync.import_model("nonexistent.xlsx")
assert False, "Expected SyncError"
except SyncError:
pass
def test_export_empty_model(self, tmp_path: Path):
sync = ExcelSync()
model = FinancialModel()
p = tmp_path / "empty.xlsx"
sync.export_model(model, p)
assert p.exists()