summaryrefslogtreecommitdiff
path: root/backend/tests/test_api.py
diff options
context:
space:
mode:
Diffstat (limited to 'backend/tests/test_api.py')
-rw-r--r--backend/tests/test_api.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/backend/tests/test_api.py b/backend/tests/test_api.py
index 22df555..b136f23 100644
--- a/backend/tests/test_api.py
+++ b/backend/tests/test_api.py
@@ -386,3 +386,40 @@ def test_overview_uses_computed_sources_and_ratios(monkeypatch) -> None:
assert overview["meta"]["sources"]["ratios.price_to_book"] == "computed"
assert overview["meta"]["field_availability"]["ratios.ev_to_ebitda"] is True
assert any(signal["key"] == "Valuation" and "24.5x" in signal["value"] for signal in overview["signals"])
+
+
+def test_financials_route_returns_structure(monkeypatch) -> None:
+ monkeypatch.setattr(
+ main.data_service,
+ "get_financials",
+ lambda symbol, period="annual": {
+ "period": "annual",
+ "income": {"columns": ["FY 2024", "TTM"], "rows": [
+ {"label": "Total Revenue", "indent": 0, "is_total": True,
+ "is_section": False, "is_margin": False, "values": [391_000.0, 394_500.0]},
+ ]},
+ "balance": {"columns": [], "rows": []},
+ "cash_flow": {"columns": [], "rows": []},
+ },
+ )
+ result = main.ticker_financials("AAPL", period="annual")
+ assert result["period"] == "annual"
+ assert result["income"]["columns"][0] == "FY 2024"
+ assert result["income"]["rows"][0]["label"] == "Total Revenue"
+
+
+def test_financials_route_period_param(monkeypatch) -> None:
+ captured: list[str] = []
+
+ def mock_get_financials(symbol, period="annual"):
+ captured.append(period)
+ return {
+ "period": period,
+ "income": {"columns": [], "rows": []},
+ "balance": {"columns": [], "rows": []},
+ "cash_flow": {"columns": [], "rows": []},
+ }
+
+ monkeypatch.setattr(main.data_service, "get_financials", mock_get_financials)
+ main.ticker_financials("AAPL", period="quarterly")
+ assert captured == ["quarterly"]