fix(runtime): release 2.7.1 with consistent ADB and failure diagnostics

This commit is contained in:
chenmingxuan committed 2026-11-05 11:40:49 +08:00
1 parent b2316ca249
commit 8bf59897bb
24 files changed
+792 -45

No files matched your search

+37 -7
View File
@@ -13,9 +13,9 @@
# limitations under the License.
from unittest.mock import MagicMock, patch
from artemis.agents.hopper.hopper import HopperOutput
from artemis.agents.hopper.hopper import HopperError, HopperOutput
from artemis.context import ArtemisContext
from artemis.tools.mobile.launch_app import find_package
from artemis.tools.mobile.launch_app import find_package, launch_app
import pytest
@@ -55,7 +55,7 @@ async def test_find_package_cache_hit(mock_hopper, mock_list_packages, mock_cont
@pytest.mark.asyncio
@patch("artemis.tools.mobile.launch_app.list_packages_async")
@patch("artemis.tools.mobile.launch_app.hopper")
async def test_find_package_not_found_caches_none(mock_hopper, mock_list_packages, mock_context):
async def test_find_package_not_found_is_not_cached(mock_hopper, mock_list_packages, mock_context):
mock_list_packages.return_value = "com.example.app1\ncom.example.app2"
# Hopper doesn't find it
@@ -64,13 +64,14 @@ async def test_find_package_not_found_caches_none(mock_hopper, mock_list_package
pkg1 = await find_package(mock_context, "App 3")
assert pkg1 is None
assert mock_hopper.call_count == 1
assert mock_context.package_cache["App 3"] is None
assert "App 3" not in mock_context.package_cache
# Second call: cache hit (None), does not call hopper again
# An earlier miss must not prevent a later successful lookup.
mock_hopper.reset_mock()
mock_hopper.return_value = HopperOutput(found=True, output="com.example.app1", reason="Found")
pkg2 = await find_package(mock_context, "App 3")
assert pkg2 is None
mock_hopper.assert_not_called()
assert pkg2 == "com.example.app1"
mock_hopper.assert_called_once()
@pytest.mark.asyncio
@@ -90,3 +91,32 @@ async def test_find_package_passes_use_fallback(mock_hopper, mock_list_packages,
data="com.example.app1\ncom.example.app2",
use_fallback=False,
)
@pytest.mark.asyncio
@patch("artemis.tools.mobile.launch_app.list_packages_async")
@patch("artemis.tools.mobile.launch_app.hopper")
async def test_model_failure_is_reported_without_poisoning_package_cache(
mock_hopper, mock_list_packages, mock_context
):
mock_list_packages.return_value = "com.example.app1"
mock_hopper.side_effect = HopperError("模型未能完成数据提取,请查看模型请求诊断。")
result = await launch_app.execute(ctx=mock_context, app_name="App 1")
assert "模型未能完成数据提取" in result
assert "Package not found" not in result
assert "App 1" not in mock_context.package_cache
mock_hopper.side_effect = None
mock_hopper.return_value = HopperOutput(found=True, output="com.example.app1", reason="Found")
assert await find_package(mock_context, "App 1") == "com.example.app1"
@pytest.mark.asyncio
@patch("artemis.tools.mobile.launch_app.list_packages_async")
@patch("artemis.tools.mobile.launch_app.hopper")
async def test_invented_package_is_never_cached(mock_hopper, mock_list_packages, mock_context):
mock_list_packages.return_value = "com.example.app1"
mock_hopper.return_value = HopperOutput(
found=True, output="com.example.missing", reason="Guess"
)
assert await find_package(mock_context, "App 1") is None
assert "App 1" not in mock_context.package_cache