fix(reports): name the sentiment analyst in the report header as users select it

- the header lists "sentiment", the name the CLI and flags use, where it printed the internal key "social"
This commit is contained in:
Yijia-Xiao
2026-10-03 21:27:43 +00:00
parent 56a98d9df7
commit 460b82e20d
3 changed files with 22 additions and 2 deletions
+14
View File
@@ -1,6 +1,7 @@
"""Report parity: the shared writer produces the report tree for the CLI and the
programmatic API alike (#1037)."""
import re
from types import SimpleNamespace
import pytest
@@ -119,3 +120,16 @@ def test_the_report_header_names_the_rating(tmp_path, decision, rating):
header = write_report_tree(state, "NVDA", tmp_path, settings=SETTINGS).read_text().split("## ")[0]
assert f"- Rating: {rating}" in header
@pytest.mark.unit
def test_the_header_names_the_analysts_as_users_select_them(tmp_path):
settings = {**SETTINGS, "analysts": ["market", "social", "news"]}
write_report_tree(_state(), "NVDA", tmp_path, settings=settings, html=True)
markdown = (tmp_path / "complete_report.md").read_text(encoding="utf-8")
assert "market, sentiment, news" in markdown and "social" not in markdown
page = (tmp_path / "complete_report.html").read_text(encoding="utf-8")
fields = re.findall(r'<span class="field">([^<]*)</span>', page)
assert {"market", "sentiment", "news"} <= set(fields) and "social" not in page