feat: add Android task file evidence and finalize plugin design
This commit is contained in:
1 parent
96fedc816f
commit
72ff342605
20 files changed
+1005
-35
No files matched your search
@@ -197,6 +197,15 @@ async def test_perception_node_async_offloading(mock_artemis_ctx, tmp_path):
|
||||
engine = DataEngine(mock_artemis_ctx)
|
||||
engine.start_session("Test Perception Node Offloading")
|
||||
mock_artemis_ctx.data_engine = engine
|
||||
image_saved = asyncio.Event()
|
||||
loop = asyncio.get_running_loop()
|
||||
save_image = engine.get_or_create_image
|
||||
|
||||
def save_image_and_signal(*args, **kwargs):
|
||||
try:
|
||||
return save_image(*args, **kwargs)
|
||||
finally:
|
||||
loop.call_soon_threadsafe(image_saved.set)
|
||||
|
||||
# Create an injected_instruction.json file
|
||||
instruction_file = Path(engine.base_dir) / "injected_instruction.json"
|
||||
@@ -214,6 +223,7 @@ async def test_perception_node_async_offloading(mock_artemis_ctx, tmp_path):
|
||||
mock_screen_data.height = 2400
|
||||
|
||||
with (
|
||||
patch.object(engine, "get_or_create_image", side_effect=save_image_and_signal),
|
||||
patch("artemis.graph.perception.UnifiedMobileController") as mock_controller_cls,
|
||||
patch("artemis.graph.perception.perform_ocr", new_callable=AsyncMock) as mock_ocr,
|
||||
patch("artemis.graph.perception._detect_status_bar_height", return_value=0),
|
||||
@@ -240,10 +250,9 @@ async def test_perception_node_async_offloading(mock_artemis_ctx, tmp_path):
|
||||
# Verify injected_instruction.json was unlinked
|
||||
assert not instruction_file.exists()
|
||||
|
||||
# Await background tasks triggered by perception_node
|
||||
await asyncio.sleep(0.1)
|
||||
if engine._pending_tasks:
|
||||
await asyncio.gather(*engine._pending_tasks)
|
||||
# perception_node creates its own task, outside engine._pending_tasks.
|
||||
# Wait for actual persistence instead of assuming the disk finishes in 100 ms.
|
||||
await asyncio.wait_for(image_saved.wait(), timeout=5)
|
||||
|
||||
# Verify image record and file were created in background by perception_node
|
||||
img_record = engine.storage.get_image(expected_hash)
|
||||
|
||||
Reference in new issue
Block a user