Files
nifodea/tests/test_forecast.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

37 lines
1.2 KiB
Python

import pytest
from application.forecast import ForecastError, ForecastService
class TestForecastService:
def test_forecast_returns_results(self, sample_model):
service = ForecastService(sample_model)
results = service.forecast_cashflow(months=12)
assert len(results) > 0
assert "balance" in results[0]
assert "month" in results[0]
def test_forecast_12_months(self, sample_model):
service = ForecastService(sample_model)
results = service.forecast_cashflow(months=12)
months = set(r["month"] for r in results)
assert max(months) == 12
def test_invalid_months(self, sample_model):
service = ForecastService(sample_model)
with pytest.raises(ForecastError):
service.forecast_cashflow(months=0)
def test_summary(self, sample_model):
service = ForecastService(sample_model)
s = service.summary(months=6)
assert "total_balance" in s
assert "total_income" in s
assert "total_expenses" in s
assert s["months"] == 6
def test_empty_model(self, empty_model):
service = ForecastService(empty_model)
results = service.forecast_cashflow(months=3)
assert results == []