Merge pull request #50 from aguzererler/test-ttm-analysis-find-col-8347777247783205733

🧪 Add unit tests for _find_col in ttm_analysis
This commit is contained in:
ahmet guzererler 2026-03-21 17:26:22 +01:00 committed by GitHub
commit 5c91aa8bb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 1 deletions

View File

@ -2,7 +2,6 @@
import pytest
import pandas as pd
from io import StringIO
# ---------------------------------------------------------------------------
@ -52,6 +51,25 @@ def _make_cashflow_csv(n_quarters: int = 8) -> str:
return df.to_csv()
# ---------------------------------------------------------------------------
# Unit tests for _find_col
# ---------------------------------------------------------------------------
class TestFindCol:
def setup_method(self):
from tradingagents.dataflows.ttm_analysis import _find_col
self.find_col = _find_col
def test_find_col_success(self):
df = pd.DataFrame({"Total Revenue": [100], "Gross Profit": [40]})
candidates = ["Revenue", "Total Revenue", "totalRevenue"]
assert self.find_col(df, candidates) == "Total Revenue"
def test_find_col_not_found(self):
df = pd.DataFrame({"Unrelated": [100], "Another": [40]})
candidates = ["Revenue", "Total Revenue", "totalRevenue"]
assert self.find_col(df, candidates) is None
# ---------------------------------------------------------------------------
# Unit tests for compute_ttm_metrics
# ---------------------------------------------------------------------------