digest: daily + weekly prompt builders (NOVICE/INTERMEDIATE)
This commit is contained in:
parent
51efccd3b1
commit
ca6b174b51
2 changed files with 143 additions and 1 deletions
48
tests/test_digest_prompts.py
Normal file
48
tests/test_digest_prompts.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
"""Unit tests for the daily / weekly digest prompt builders."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from app.services.openrouter import (
|
||||
build_daily_digest_prompt,
|
||||
build_weekly_digest_prompt,
|
||||
)
|
||||
|
||||
|
||||
def _ctx():
|
||||
return dict(
|
||||
today=datetime(2026, 5, 25, 6, 30, tzinfo=timezone.utc),
|
||||
quotes_by_group={"equities": [{"symbol": "SPX", "price": 7500.0,
|
||||
"label": "S&P 500", "currency": "USD",
|
||||
"source": "test", "note": "",
|
||||
"as_of": None, "changes": {}}]},
|
||||
headlines_by_bucket={"general": [{"when": "2026-05-25T05:00:00+00:00",
|
||||
"source": "FT", "title": "Brent slides"}]},
|
||||
reference_line="S&P 7,501 (ATH) · VIX 18.0 · US 10y 4.45%",
|
||||
)
|
||||
|
||||
|
||||
def test_daily_prompt_tone_intermediate():
|
||||
sys_, usr = build_daily_digest_prompt(tone="INTERMEDIATE", **_ctx())
|
||||
assert "INTERMEDIATE" in sys_.upper() or "intermediate" in sys_.lower()
|
||||
assert "Brent slides" in usr
|
||||
assert "daily" in sys_.lower()
|
||||
|
||||
|
||||
def test_daily_prompt_tone_novice_differs():
|
||||
sys_int, _ = build_daily_digest_prompt(tone="INTERMEDIATE", **_ctx())
|
||||
sys_nov, _ = build_daily_digest_prompt(tone="NOVICE", **_ctx())
|
||||
assert sys_int != sys_nov
|
||||
|
||||
|
||||
def test_weekly_prompt_mentions_week():
|
||||
sys_, usr = build_weekly_digest_prompt(tone="INTERMEDIATE", **_ctx())
|
||||
assert "week" in sys_.lower() or "weekly" in sys_.lower()
|
||||
assert "Brent slides" in usr
|
||||
|
||||
|
||||
def test_prompts_return_strings():
|
||||
for fn in (build_daily_digest_prompt, build_weekly_digest_prompt):
|
||||
sys_, usr = fn(tone="INTERMEDIATE", **_ctx())
|
||||
assert isinstance(sys_, str) and isinstance(usr, str)
|
||||
assert len(sys_) > 50 and len(usr) > 50
|
||||
Loading…
Add table
Add a link
Reference in a new issue