Tests / Test apps.device-host-agent.tests.test_mcp_token.test_load_or_create_concurrent_calls_do_not_corrupt failed
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timedelta, timezone
|
|
|
|
from runtime.planner_prompts import planner_user_prompt
|
|
|
|
|
|
def test_planner_user_prompt_includes_time_zone_and_configured_device_type() -> None:
|
|
prompt = planner_user_prompt(
|
|
goal="open settings",
|
|
scene_json={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
device_platform="ios",
|
|
now=datetime(
|
|
2026,
|
|
7,
|
|
16,
|
|
9,
|
|
8,
|
|
7,
|
|
tzinfo=timezone(timedelta(hours=8), "Asia/Shanghai"),
|
|
),
|
|
)
|
|
|
|
assert "Current date and time: 2026-07-16T09:08:07+08:00" in prompt
|
|
assert "Time zone: Asia/Shanghai" in prompt
|
|
assert "Device type: ios" in prompt
|
|
|
|
|
|
def test_planner_user_prompt_uses_scene_platform_when_context_is_unavailable() -> None:
|
|
prompt = planner_user_prompt(
|
|
goal="open settings",
|
|
scene_json={
|
|
"screen": {"width": 1, "height": 1},
|
|
"elements": [],
|
|
"app": {"platform": "android"},
|
|
},
|
|
now=datetime(2026, 7, 16, tzinfo=timezone.utc),
|
|
)
|
|
|
|
assert "Device type: android" in prompt
|
|
|
|
|
|
def test_planner_user_prompt_does_not_duplicate_conversation_history() -> None:
|
|
prompt = planner_user_prompt(
|
|
goal="open settings",
|
|
scene_json={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
)
|
|
|
|
assert "Recent history" not in prompt
|