mirror of
https://github.com/shawnkim1997/All-in-one-Financial-Analysis.git
synced 2026-08-16 03:48:07 +00:00
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""Tests for earnings transcript delta analysis."""
|
|
|
|
from datetime import date
|
|
|
|
from server.services.earnings_transcripts import Transcript, compute_delta, default_quarter_pair, tokenize_and_normalize
|
|
|
|
|
|
def test_default_quarter_pair_uses_completed_quarter() -> None:
|
|
current, previous = default_quarter_pair(date(2026, 4, 21))
|
|
|
|
assert current == (2026, 1)
|
|
assert previous == (2025, 4)
|
|
|
|
|
|
def test_tokenize_and_normalize_removes_common_call_words() -> None:
|
|
tokens = tokenize_and_normalize("Thank you operator. Sovereign AI demand was strong, strong, strong.")
|
|
lemmas = [token.lemma for token in tokens]
|
|
|
|
assert "thank" not in lemmas
|
|
assert "operator" not in lemmas
|
|
assert "sovereign" in lemmas
|
|
assert lemmas.count("strong") == 3
|
|
|
|
|
|
def test_compute_delta_surfaces_new_removed_and_emphasis_phrases() -> None:
|
|
previous = Transcript(
|
|
ticker="NVDA",
|
|
year=2025,
|
|
quarter=4,
|
|
content="inventory correction inventory correction gaming demand gaming demand data center",
|
|
)
|
|
current = Transcript(
|
|
ticker="NVDA",
|
|
year=2026,
|
|
quarter=1,
|
|
content="sovereign AI sovereign AI AI infrastructure AI infrastructure data center data center data center",
|
|
)
|
|
|
|
delta = compute_delta(current, previous)
|
|
|
|
assert delta["available"] is True
|
|
assert any(row["phrase"] == "sovereign ai" for row in delta["new_phrases"])
|
|
assert any(row["phrase"] == "inventory correction" for row in delta["removed_phrases"])
|
|
assert any(row["phrase"] == "data center" for row in delta["emphasis_shift"])
|
|
assert any(row["topic"] == "AI / Data Centre" for row in delta["topic_shift"])
|
|
assert "delta" in delta["tone_shift"]
|