中国城市电报推送接入 AMSC AWOS 跑道报文温度
Constraint: 仅当 amos 数据含 raw_metar 时才追加 AMSC 块,不影响非中国城市
This commit is contained in:
@@ -327,6 +327,7 @@ def build_city_query_report(
|
||||
open_meteo = weather_data.get("open-meteo", {}) or {}
|
||||
metar = weather_data.get("metar", {}) or {}
|
||||
mgm = weather_data.get("mgm") or {}
|
||||
amos = weather_data.get("amos") or {}
|
||||
settlement_current = weather_data.get("settlement_current") or {}
|
||||
if not isinstance(settlement_current, dict):
|
||||
settlement_current = {}
|
||||
@@ -522,6 +523,25 @@ def build_city_query_report(
|
||||
f"\n✈️ <b>实测 ({main_source}): {cur_temp}{temp_symbol}</b>{max_str} |{wx_display} | {obs_t_str}{age_tag}"
|
||||
)
|
||||
|
||||
# --- AMSC AWOS runway & METAR detail for Chinese cities ---
|
||||
amos_raw_metar = str(amos.get("raw_metar") or "").strip()
|
||||
if amos_raw_metar:
|
||||
amos_temp = amos.get("temp_c")
|
||||
amos_label = amos.get("source_label") or "AMSC AWOS"
|
||||
amos_otime = amos.get("observation_time_local") or ""
|
||||
parts = [f"🛰️ <b>{amos_label}</b>"]
|
||||
if amos_temp is not None:
|
||||
parts.append(f"跑道气温: {amos_temp:.1f}{temp_symbol}")
|
||||
if amos_otime:
|
||||
parts.append(f"观测时间: {amos_otime}")
|
||||
if amos_raw_metar:
|
||||
# Shorten: keep only the METAR body, strip the leading METAR prefix
|
||||
metar_body = amos_raw_metar
|
||||
if metar_body.upper().startswith("METAR "):
|
||||
metar_body = metar_body[6:]
|
||||
parts.append(f"报文: {metar_body}")
|
||||
msg_lines.append(" | ".join(parts))
|
||||
|
||||
if use_settlement_current:
|
||||
# HKO/CWA detailed observations
|
||||
wind = primary_current.get("wind_speed_kt")
|
||||
@@ -559,7 +579,7 @@ def build_city_query_report(
|
||||
if line.strip():
|
||||
msg_lines.append(f"- {line.strip()}")
|
||||
metar_narrative = describe_metar_report(
|
||||
raw_metar=str(primary_current.get("raw_metar") or metar_current.get("raw_metar") or ""),
|
||||
raw_metar=str(amos_raw_metar or primary_current.get("raw_metar") or metar_current.get("raw_metar") or ""),
|
||||
temp_symbol=temp_symbol,
|
||||
fallback={
|
||||
"icao": metar.get("icao"),
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
from scripts.grant_subscription_by_email import _select_exact_user_id
|
||||
from src.payments.contract_checkout import PaymentCheckoutError
|
||||
|
||||
|
||||
def test_select_exact_user_id_prefers_exact_email_match():
|
||||
payload = {
|
||||
"users": [
|
||||
{"id": "wrong-user", "email": "louischanre+alias@gmail.com"},
|
||||
{"id": "right-user", "email": "louischanre@gmail.com"},
|
||||
]
|
||||
}
|
||||
|
||||
result = _select_exact_user_id(payload, "louischanre@gmail.com")
|
||||
|
||||
assert result == "right-user"
|
||||
|
||||
|
||||
def test_select_exact_user_id_raises_when_exact_email_missing():
|
||||
payload = {
|
||||
"users": [
|
||||
{"id": "wrong-user", "email": "louischanre+alias@gmail.com"},
|
||||
]
|
||||
}
|
||||
|
||||
try:
|
||||
_select_exact_user_id(payload, "louischanre@gmail.com")
|
||||
except PaymentCheckoutError as exc:
|
||||
assert exc.status_code == 404
|
||||
else:
|
||||
raise AssertionError("expected PaymentCheckoutError")
|
||||
Reference in New Issue
Block a user