33 lines
965 B
Python
33 lines
965 B
Python
from __future__ import annotations
|
|
|
|
from app.features.push_payload import build_home_push_data
|
|
|
|
|
|
def test_build_home_push_data_contains_home_route_fields() -> None:
|
|
payload = build_home_push_data(
|
|
client_user_id="client-123",
|
|
body="今天也请温柔地对自己说话。",
|
|
scene="push",
|
|
content_id=9,
|
|
)
|
|
|
|
assert payload == {
|
|
"client_user_id": "client-123",
|
|
"scene": "push",
|
|
"target_screen": "home",
|
|
"deep_link": "client://home",
|
|
"home_text": "今天也请温柔地对自己说话。",
|
|
"content_id": 9,
|
|
}
|
|
|
|
|
|
def test_build_home_push_data_omits_content_id_when_missing() -> None:
|
|
payload = build_home_push_data(
|
|
client_user_id="client-123",
|
|
body="先看到这句,再回到首页。",
|
|
)
|
|
|
|
assert "content_id" not in payload
|
|
assert payload["target_screen"] == "home"
|
|
assert payload["home_text"] == "先看到这句,再回到首页。"
|