feat: add weekly reward loop, i18n support, and scan terminal dashboard components
This commit is contained in:
@@ -3,11 +3,16 @@ from src.utils.telegram_push import (
|
||||
HIGH_FREQ_AIRPORT_ICAO,
|
||||
_build_airport_status_message,
|
||||
_run_high_freq_airport_cycle,
|
||||
_telegram_push_language,
|
||||
)
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_airport_status_message_starts_with_runway_city_and_station_hashtags():
|
||||
def test_airport_status_message_defaults_to_bilingual_runway_copy(monkeypatch):
|
||||
monkeypatch.delenv("TELEGRAM_AIRPORT_PUSH_LANGUAGE", raising=False)
|
||||
monkeypatch.delenv("TELEGRAM_PUSH_LANGUAGE", raising=False)
|
||||
monkeypatch.delenv("POLYWEATHER_TELEGRAM_PUSH_LANGUAGE", raising=False)
|
||||
|
||||
text = _build_airport_status_message(
|
||||
"qingdao",
|
||||
{
|
||||
@@ -32,10 +37,13 @@ def test_airport_status_message_starts_with_runway_city_and_station_hashtags():
|
||||
)
|
||||
|
||||
first_line = text.splitlines()[0]
|
||||
assert first_line == "#跑道观测 #Qingdao"
|
||||
assert _telegram_push_language() == "both"
|
||||
assert first_line == "#RunwayObs #跑道观测 #Qingdao"
|
||||
assert "Qingdao / Jiaodong" in text
|
||||
assert "TDZ:23.0" in text
|
||||
assert "DEB" in text and "24.0" in text
|
||||
assert "Runway now / 跑道当前:" in text
|
||||
assert "Today's runway high / 今日跑道高点:" in text
|
||||
assert "DEB: 24.0°C" in text
|
||||
|
||||
|
||||
def test_airport_status_hides_non_focus_runways_for_key_airports():
|
||||
@@ -62,7 +70,7 @@ def test_airport_status_hides_non_focus_runways_for_key_airports():
|
||||
|
||||
assert "02L/20R" in text
|
||||
assert "02R/20L" in text
|
||||
assert "结算跑道当前:31.2°C" in text
|
||||
assert "Settlement runway now / 结算跑道当前: 31.2°C" in text
|
||||
|
||||
|
||||
def test_singapore_is_in_telegram_push_city_lists():
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
from src.bot.weekly_reward_loop import _render_settle_report
|
||||
from src.utils.daily_weather_report import _build_ai_prompt
|
||||
from src.utils.telegram_i18n import copy_text, telegram_push_language
|
||||
|
||||
|
||||
def test_telegram_push_language_defaults_to_bilingual(monkeypatch):
|
||||
monkeypatch.delenv("TELEGRAM_PUSH_LANGUAGE", raising=False)
|
||||
monkeypatch.delenv("POLYWEATHER_TELEGRAM_PUSH_LANGUAGE", raising=False)
|
||||
|
||||
assert telegram_push_language() == "both"
|
||||
assert copy_text("both", "Current", "当前") == "Current / 当前"
|
||||
|
||||
|
||||
def test_daily_weather_report_prompt_defaults_to_bilingual(monkeypatch):
|
||||
monkeypatch.delenv("DAILY_WEATHER_REPORT_LANGUAGE", raising=False)
|
||||
monkeypatch.delenv("TELEGRAM_PUSH_LANGUAGE", raising=False)
|
||||
|
||||
prompt = _build_ai_prompt(
|
||||
[
|
||||
{
|
||||
"city": "beijing",
|
||||
"name": "北京",
|
||||
"name_en": "Beijing",
|
||||
"weather": "晴",
|
||||
"forecast_high": 28.0,
|
||||
}
|
||||
],
|
||||
"05月27日",
|
||||
)
|
||||
|
||||
assert "bilingual Telegram weather briefing" in prompt
|
||||
assert "Beijing / 北京" in prompt
|
||||
assert "English first then Chinese" in prompt
|
||||
|
||||
|
||||
def test_weekly_reward_report_defaults_to_bilingual(monkeypatch):
|
||||
monkeypatch.delenv("POLYWEATHER_WEEKLY_REWARD_LANGUAGE", raising=False)
|
||||
monkeypatch.delenv("TELEGRAM_PUSH_LANGUAGE", raising=False)
|
||||
|
||||
text = _render_settle_report(
|
||||
week_key="2026-W21",
|
||||
winners=[
|
||||
{
|
||||
"rank": 1,
|
||||
"username": "ada",
|
||||
"points_bonus": 200,
|
||||
"pro_days": 7,
|
||||
}
|
||||
],
|
||||
skipped=1,
|
||||
participation_count=3,
|
||||
active_count=1,
|
||||
)
|
||||
|
||||
assert "weekly rewards settled" in text
|
||||
assert "周榜奖励已结算" in text
|
||||
assert "points / 积分" in text
|
||||
assert "Participation bonus" in text
|
||||
assert "参与奖" in text
|
||||
Reference in New Issue
Block a user