diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-18 00:44:58 -0700 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-18 00:44:58 -0700 |
| commit | 147664128fa0281333ba3150e007ed8e2f6a616a (patch) | |
| tree | 3a0dcc1cf852d4b6c2b1aa27d571db7216515f6d /backend/tests | |
| parent | 089933091751213b320728ba0247d22c757ebacf (diff) | |
various
Diffstat (limited to 'backend/tests')
| -rw-r--r-- | backend/tests/test_api.py | 37 |
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"] |
