summaryrefslogtreecommitdiff
path: root/backend/tests/test_api.py
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-05-18 00:15:12 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-05-18 00:15:12 -0700
commit28f9aae05d8b46a3fe6ca3d5bbce34634604db05 (patch)
tree171acf5d3cf5294f9b38d15686730dbb06486ec1 /backend/tests/test_api.py
parent1df80dc1f868b906c5540b66a211947c6886484d (diff)
feat: add /api/tickers/{symbol}/financials endpoint
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 f98b582..e5dcead 100644
--- a/backend/tests/test_api.py
+++ b/backend/tests/test_api.py
@@ -543,3 +543,40 @@ def test_get_financials_empty_statements(monkeypatch) -> None:
assert result["income"]["rows"] == []
assert result["balance"]["columns"] == []
assert result["cash_flow"]["columns"] == []
+
+
+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"]