summaryrefslogtreecommitdiff
path: root/backend/tests
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-05-18 23:59:37 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-05-18 23:59:37 -0700
commit38f8664eccd7738855918fff0537335f7238a006 (patch)
treeac3b3cbbc742115482487c3ce6cd4394fa9fcd63 /backend/tests
parent66cfb26ebd8fa44b24e37b4ffc796ab29dcbd704 (diff)
feat: add projection_years to DcfResult schema and service output
Add projection_years: int = 5 field to the DcfResult Pydantic schema and emit it from the data_service.get_valuation() function across all three dcf_out cases (unavailable, error, and successful). This enables frontend DCF sliders to know the default projection horizon. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend/tests')
-rw-r--r--backend/tests/test_api.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/backend/tests/test_api.py b/backend/tests/test_api.py
index 345c0a3..230182e 100644
--- a/backend/tests/test_api.py
+++ b/backend/tests/test_api.py
@@ -633,6 +633,36 @@ def test_valuation_schema_structure() -> None:
assert resp.ev_revenue.available is False
+def test_dcf_result_projection_years_default() -> None:
+ from app.schemas import DcfResult
+ dcf = DcfResult(available=False)
+ assert dcf.projection_years == 5
+
+
+def test_get_valuation_includes_projection_years(monkeypatch) -> None:
+ import pandas as pd
+ clear_service_caches()
+ monkeypatch.setattr(
+ data_service, "get_company_info",
+ lambda symbol: {
+ "currentPrice": 150.0,
+ "sharesOutstanding": 1_000_000_000.0,
+ "totalDebt": 0.0,
+ "totalCash": 0.0,
+ },
+ )
+ monkeypatch.setattr(data_service, "get_shares_outstanding", lambda symbol: 1_000_000_000.0)
+ cf = annual_frame({
+ "Operating Cash Flow": [80.0, 90.0, 100.0, 110.0],
+ "Capital Expenditure": [-10.0, -10.0, -10.0, -10.0],
+ })
+ monkeypatch.setattr(data_service, "get_cash_flow", lambda symbol, quarterly=False: cf if not quarterly else pd.DataFrame())
+ monkeypatch.setattr(data_service, "get_income_statement", lambda symbol, quarterly=False: pd.DataFrame())
+ monkeypatch.setattr(data_service, "get_balance_sheet", lambda symbol, quarterly=False: pd.DataFrame())
+ result = data_service.get_valuation("AAPL")
+ assert result["dcf"]["projection_years"] == 5
+
+
def test_build_fcf_series_happy_path() -> None:
cf = annual_frame({
"Operating Cash Flow": [100.0, 90.0, 80.0, 70.0],